utils
Module¶
This file specifically includes utilities for security.¶
-
gluon.utils.
AES_new
(key, IV=None)[source]¶ Returns an AES cipher object and random IV if None specified
-
gluon.utils.
fast_urandom16
(urandom=[], locker=<_RLock owner=None count=0>)[source]¶ This is 4x faster than calling os.urandom(16) and prevents the “too many files open” issue with concurrent access to os.urandom()
-
gluon.utils.
initialize_urandom
()[source]¶ 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.
-
gluon.utils.
is_loopback_ip_address
(ip=None, addrinfo=None)[source]¶ Determines whether the address appears to be a loopback address. This assumes that the IP is valid.
-
gluon.utils.
is_valid_ip_address
(address)[source]¶ Examples
Better than a thousand words:
>>> is_valid_ip_address('127.0') False >>> is_valid_ip_address('127.0.0.1') True >>> is_valid_ip_address('2001:660::1') True
-
gluon.utils.
simple_hash
(text, key='', salt='', digest_alg='md5')[source]¶ Generates hash with the given text using the specified digest hashing algorithm
-
gluon.utils.
web2py_uuid
(ctokens=(4774988260019225156, 367960655099462939))[source]¶ 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.