Package openid :: Module cryptutil
[hide private]
[frames] | no frames]

Module cryptutil

source code

Module containing a cryptographic-quality source of randomness and other cryptographically useful functionality

Python 2.4 needs no external support for this module, nor does Python 2.3 on a system with /dev/urandom.

Other configurations will need a quality source of random bytes and access to a function that will convert binary strings to long integers. This module will work with the Python Cryptography Toolkit (pycrypto) if it is present. pycrypto can be found with a search engine, but is currently found at:

http://www.amk.ca/python/code/crypto

Classes [hide private]
  HashContainer
Functions [hide private]
 
hmacSha1(key, text) source code
 
sha1(s) source code
 
hmacSha256(key, text) source code
 
sha256(s) source code
 
reversed(seq) source code
 
longToBinary(l) source code
 
binaryToLong(s) source code
 
randrange(start, stop=None, step=1, _int=<type 'int'>, _maxwidth=9007199254740992)
Choose a random item from range(start, stop[, step]).
 
longToBase64(l) source code
 
base64ToLong(s) source code
 
randomString(length, chrs=None)
Produce a string of length random bytes, chosen from chrs.
source code
Variables [hide private]
  sha1_module = HashContainer(hashlib.sha1)
  sha256_module = HashContainer(hashlib.sha256)
  _no_sha256 = NotImplementedError('Use Python 2.5, install pycr...
  SHA256_AVAILABLE = True
  _urandom = file('/dev/urandom', 'rb')
  _pool = RandomPool()
  _duplicate_cache = {}
  __package__ = 'openid'
Function Details [hide private]

randrange(start, stop=None, step=1, _int=<type 'int'>, _maxwidth=9007199254740992)

 

Choose a random item from range(start, stop[, step]).

This fixes the problem with randint() which includes the endpoint; in Python this is usually not what you want.


Variables Details [hide private]

_no_sha256

Value:
NotImplementedError('Use Python 2.5, install pycrypto or install hashl\
ib to use SHA256')