Skip to main content

cryptacular

cryptacular is a collection of strong password hashing functions that share a common interface, and a nice way to use bcrypt as a password hash. It’s designed to make it easy for you to migrate away from your half-assed custom password scheme. Compared with popular choices like plain text or single rounds of md5 or sha, strong password hashes greatly increase the computational cost of obtaining users’ passwords from a leaked password database.

cryptacular’s interface was inspired by zope.password but cryptacular does not depend on zope and implements much stronger algorithms. cryptacular also provides a convenient way to recognize and upgrade obsolete password hashes on the fly when users log in with their correct password.

z3c.bcrypt integrates cryptacular into zope.password.

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 this property. They also 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 (abstract base classes) PasswordChecker and PasswordManager.

DelegatingPasswordManager is the recommended way to use cryptacular. DelegatingPasswordManager holds a preferred cryptacular.core.PasswordManager instance that can encode and check password hashes and a list of fallback cryptacular.core.PasswordChecker instances that are only required to be able to check password hashes (no need to implement InsecurePasswordHash.encode()). When asked to check a password hash against a plaintext password, DelegatingPasswordManager finds the first item in its list that understands the given hash format and uses it to check the password. If the password was correct but not in the preferred hash format, DelegatingPasswordManager will re-hash the given password using its preferred PasswordManager.

>>> 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 a C extension module to call 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. You can use this even if you cannot run C extension modules in your Python.

0.5

  • use normal Python extension module instead of ctypes for bcrypt

0.4

  • don’t import ez_setup

  • MANIFEST.in includes self

  • use regular import to declare the namespace package

0.3

  • fix i386 build

0.2

  • cryptacular is now a namespace package. Compatible password hashing implementations can go under cryptacular.``name``

0.1

  • Initial release

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.5.1.tar.gz (34.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cryptacular-0.5.1.win32-py2.7.msi (147.5 kB view details)

Uploaded Source

cryptacular-0.5.1.win32-py2.6.msi (131.1 kB view details)

Uploaded Source

cryptacular-0.5.1-py2.7-win32.egg (34.0 kB view details)

Uploaded Egg

cryptacular-0.5.1-py2.6-win32.egg (34.2 kB view details)

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for cryptacular-0.5.1.tar.gz
Algorithm Hash digest
SHA256 cc251979c390b34cf4483b89336192c9685d6b6cace7161021f1da01f5bc022e
MD5 9bf20f6eecefa1ca9217792f8b72c589
BLAKE2b-256 49748e553b96c7d95ee9451a5aeecc6ac9daecf0460f246187f59235d0640c60

See more details on using hashes here.

File details

Details for the file cryptacular-0.5.1.win32-py2.7.msi.

File metadata

File hashes

Hashes for cryptacular-0.5.1.win32-py2.7.msi
Algorithm Hash digest
SHA256 ac0f3582e8ef8d5254b624bdd8603c185b669295858df1d86b74c5b68f9e492e
MD5 618444ea92ba04ec3a34cf2e6f221c67
BLAKE2b-256 e4e8a63468a7c608f77efbff9be14875a65af4745b58720d9d41b1da4dbadb0a

See more details on using hashes here.

File details

Details for the file cryptacular-0.5.1.win32-py2.6.msi.

File metadata

File hashes

Hashes for cryptacular-0.5.1.win32-py2.6.msi
Algorithm Hash digest
SHA256 98c5c726ff9b4f183a815123c32c361068013fab9cde78e91267d6d629e9ec4d
MD5 cdc0cf9b354e06d2a834c90990addb8a
BLAKE2b-256 bc56b0b2832bbf5b289671c0e6b0a89e81c051df407985ab81687cb2e311a383

See more details on using hashes here.

File details

Details for the file cryptacular-0.5.1-py2.7-win32.egg.

File metadata

File hashes

Hashes for cryptacular-0.5.1-py2.7-win32.egg
Algorithm Hash digest
SHA256 c0c9f0e8af2d740979005b3724243a711d2b60689626c30eb80d1d354c75f3c5
MD5 dc169c0d0edb6532363affb70475a1cd
BLAKE2b-256 3ba70afd29b93539d21974d4c6899ed29b33a27cd41643274f033d21602475d9

See more details on using hashes here.

File details

Details for the file cryptacular-0.5.1-py2.6-win32.egg.

File metadata

File hashes

Hashes for cryptacular-0.5.1-py2.6-win32.egg
Algorithm Hash digest
SHA256 cdf88e5c83b741f76f5b1a25a34d40a9cbbb6f686f29db8eeab2a176d545f76a
MD5 0b2d8c000c868a4c55c87755f941960e
BLAKE2b-256 f1c82730a701c034b19de688ea7ba36c26d16ef0fa36eec513e6ec607e861f50

See more details on using hashes here.

Release history Release notifications | RSS feed

1.6.2

1 file

1.6.1

1 file

1.6.0

1 file

1.5.5

1 file

1.5.1

1 file

1.5.0

2 files

1.4.1

1 file

1.4

1 file

1.3

1 file

1.2.1

1 file

1.2

1 file

1.0

1 file

0.9

1 file

This release

0.5.1 This release

5 files

0.5

1 file

0.4

1 file

0.3

1 file

0.2

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page