Skip to main content

A pbkdf2 and public-domain bcrypt password hashing framework.

Project description

cryptacular is a collection of password hashing functions that share a common interface. It’s designed to make it easy for you to migrate away from your half-assed custom password scheme. Use bcrypt if you are able to run C code in your Python and pbkdf2 if you are not.

cryptacular’s interface was inspired by zope.password. Unlike zope.password it includes schemes that are strong enough for modern use and it does not depend on zope.

http://chargen.matasano.com/chargen/2007/9/7/enough-with-the-rainbow-tables-what-you-need-to-know-about-s.html explains why bcrypt is a good idea. Computers are fast now. To protect our users against a leaked password database, we should use password hashes that take a little longer to check than sha1(salt + hash). bcrypt and pbkdf2 have parametric complexity so they can be made stronger as computers continue to get faster.

cryptacular ships with 100% test coverage.

cryptacular.core

cryptacular.core defines the DelegatingPasswordManager and the interfaces PasswordChecker and PasswordManager. DelegatingPasswordManager fallbacks are PasswordChecker instances that need not implement password encoding, e.g. do not implement InsecurePasswordScheme().encode()

>>> import cryptacular.core
>>> import cryptacular.bcrypt
>>> import cryptacular.pbkdf2
>>> bcrypt = cryptacular.bcrypt.BCRYPTPasswordManager()
>>> pbkdf2 = cryptacular.pbkdf2.PBKDF2PasswordManager()
>>> delegator = cryptacular.core.DelegatingPasswordManager(preferred=bcrypt, fallbacks=(pbkdf2,))
>>> users = {'one':{'password':'xyzzy'}, 'two':{'password':u'hashy the \N{SNOWMAN}'}}
>>> for key in users: users[key]['hash'] = pbkdf2.encode(users[key]['password'])
>>> bcrypt.match(users['one']['password'])
False
>>> def set_hash(hash): users['one']['hash'] = hash
>>> delegator.check(users['one']['hash'], users['one']['password'], setter=set_hash)
True
>>> bcrypt.match(users['one']['hash'])
True
>>> def set_hash(hash): raise Exception("Should not re-set a preferred hash")
>>> delegator.check(users['one']['hash'], users['one']['password'], setter=set_hash)
True
>>> bcrypt.match(users['two']['hash'])
False
>>> pbkdf2.match(users['two']['hash'])
True
>>> delegator.check(users['two']['hash'], users['two']['password'])
True
>>> bcrypt.match(users['two']['hash'])
False
>>> pbkdf2.match(users['two']['hash'])
True

cryptacular.bcrypt

cryptacular.bcrypt uses ctypes to access the public-domain crypt_blowfish (http://www.openwall.com/crypt/) which is bundled with cryptacular. You should use this if you can.

cryptacular.pbkdf2

cryptacular.pbkdf2 applies the pbkdf2 key derivation algorithm described in RFC 2898 as a password hash. It uses M2Crypto.EVP.pbkdf2 with a Python fallback when M2Crypto is not available.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cryptacular-0.1.tar.gz (32.3 kB view details)

Uploaded Source

File details

Details for the file cryptacular-0.1.tar.gz.

File metadata

  • Download URL: cryptacular-0.1.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cryptacular-0.1.tar.gz
Algorithm Hash digest
SHA256 e4ad2fd3d02f2815c82ad7577374e54850c425bd920df20d316d900eeb49535c
MD5 9ec891213806f9ce03950af4ea7650fc
BLAKE2b-256 8260c74890ca98ae2fb6b6460c825bf62378de7b2ec73b4dcd53adab1d2a8b65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page