Crypto Utility API

glashammer.crypto

copyright:2007-2009-2008 by Armin Ronacher
license:MIT
glashammer.utils.crypto.check_pwhash(pwhash, password)

Check a password against a given hash value. Since many forums save md5 passwords with no salt and it’s technically impossible to convert this to a hash with a salt we use this to be able to check for plain passwords:

plain$$default

md5 passwords without salt:

md5$$c21f969b5f03d33d43e04f8f136e7682

md5 passwords with salt:

md5$123456$7faa731e3365037d264ae6c2e3c7697e

sha(sha-0) passwords:

sha$123456$118083bd04c79ab51944a9ef863efcd9c048dd9a

sha1 passwords:

sha1$123456$118083bd04c79ab51944a9ef863efcd9c048dd9a

Note that the integral passwd column in the table is only 60 chars long. If you have a very large salt or the plaintext password is too long it will be truncated.

glashammer.utils.crypto.gen_pwhash(password, method='sha1')
Return the password hashed with a random salt.
glashammer.utils.crypto.gen_random_identifier(length=8)
Generate a random identifier.
glashammer.utils.crypto.gen_salt(length=6)
Generate a random string of SALT_CHARS with specified length.