/[glsr]/trunk/harmonious/_sessionutils.py
Gentoo

Contents of /trunk/harmonious/_sessionutils.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (show annotations) (download) (as text)
Fri Jun 24 17:15:20 2005 UTC (9 years, 2 months ago) by port001
File MIME type: text/x-python
File size: 591 byte(s)
Fixed session id generation
1 __id__ = '$Id$'
2 __modulename__ = '_sessionutils'
3
4 import sha
5 import hmac
6 from time import time
7 from random import Random
8
9 from harmonious import harm
10
11 def _gen_hash(sid):
12
13 return hmac.new(harm.config.server['SecretKey'], sid, sha).hexdigest()[:10]
14
15 def _gen_sid(client_addr):
16
17 ran = Random()
18
19 return sha.new(str(time() * ran.randint(0, 10000000000000000000000000)) + \
20 str(client_addr)).hexdigest()[:10]
21
22 # TODO: Just using the client IP addr isn't great.
23
24 def gen_session_id(client_addr):
25
26 sid = _gen_sid(client_addr)
27
28 return sid + _gen_hash(sid)

Properties

Name Value
svn:keyword Id
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.20