Package web2py :: Package gluon :: Module utils
[hide private]
[frames] | no frames]

Module utils

source code

This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)

This file specifically includes utilities for security.

Functions [hide private]
 
md5_hash(text)
Generate a md5 hash with the given text
source code
 
simple_hash(text, digest_alg='md5')
Generates hash with the given text using the specified digest hashing algorithm
source code
 
get_digest(value)
Returns a hashlib digest algorithm from a string
source code
 
hmac_hash(value, key, digest_alg='md5', salt=1) source code
 
initialize_urandom()
This function and the web2py_uuid follow from the following discussion: http://groups.google.com/group/web2py-developers/browse_thread/thread/7fd5789a7da3f09
source code
 
web2py_uuid()
This function follows from the following discussion: http://groups.google.com/group/web2py-developers/browse_thread/thread/7fd5789a7da3f09
source code
Variables [hide private]
  logger = logging.getLogger("web2py")
  ctokens = [176, 173, 75, 184, 184, 169, 176, 173, 75, 184, 184...
Function Details [hide private]

initialize_urandom()

source code 

This function and the web2py_uuid follow from the following discussion: http://groups.google.com/group/web2py-developers/browse_thread/thread/7fd5789a7da3f09

At startup web2py compute a unique ID that identifies the machine by adding uuid.getnode() + int(time.time() * 1e3)

This is a 48-bit number. It converts the number into 16 8-bit tokens. It uses this value to initialize the entropy source ('/dev/urandom') and to seed random.

If os.random() is not supported, it falls back to using random and issues a warning.

web2py_uuid()

source code 

This function follows from the following discussion: http://groups.google.com/group/web2py-developers/browse_thread/thread/7fd5789a7da3f09

It works like uuid.uuid4 except that tries to use os.urandom() if possible and it XORs the output with the tokens uniquely associated with this machine.

Variables Details [hide private]

ctokens

Value:
[176,
 173,
 75,
 184,
 184,
 169,
 176,
 173,
...