| Home | Trees | Indices | Help |
|
|---|
|
|
Unix crypt(3) password hash algorithm. This is a port to Python of the standard Unix password crypt function. It's a single self-contained source file that works with any version of Python from version 1.5 or higher. The code is based on Eric Young's optimised crypt in C. Python fcrypt is intended for users whose Python installation has not had the crypt module enabled, or whose C library doesn't include the crypt function. See the documentation for the Python crypt module for more information: http://www.python.org/doc/current/lib/module-crypt.html An alternative Python crypt module that uses the MD5 algorithm and is more secure than fcrypt is available from michal j wallace at: http://www.sabren.net/code/python/crypt/index.php3 The crypt() function is a one-way hash function, intended to hide a password such that the only way to find out the original password is to guess values until you get a match. If you need to encrypt and decrypt data, this is not the module for you. There are at least two packages providing Python cryptography support: M2Crypto at <http://www.pobox.org.sg/home/ngps/m2/>, and amkCrypto at <http://www.amk.ca/python/code/crypto.html>. Functions: crypt() -- return hashed password
Version: 1.3.1
Date: 21 February 2004
Author: Carey Evans <careye@spamcop.net>
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
__credits__ = '''michal j wallace for inspiring me to write th
|
|||
_ITERATIONS = 16
|
|||
_SPtrans = [0x00820200, 0x00020000, 0x80800000, 0x80820200, 0x
|
|||
_skb = [0x00000000, 0x00000010, 0x20000000, 0x20000010, 0x0001
|
|||
_shifts2 = 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0
|
|||
_con_salt = [0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0
|
|||
_cov_2char = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij
|
|||
|
|||
Generate an encrypted hash from the passed password. If the password is longer than eight characters, only the first eight will be used. The first two characters of the salt are used to modify the encryption algorithm used to generate in the hash in one of 4096 different ways. The characters for the salt should be upper- and lower-case letters A to Z, digits 0 to 9, '.' and '/'. The returned hash begins with the two characters of the salt, and should be passed as the salt to verify the password. Example: >>> from fcrypt import crypt >>> password = 'AlOtBsOl' >>> salt = 'cE' >>> hash = crypt(password, salt) >>> hash 'cEpWz5IUCShqM' >>> crypt(password, hash) == hash 1 >>> crypt('IaLaIoK', hash) == hash 0 In practice, you would read the password using something like the getpass module, and generate the salt randomly: >>> import random, string >>> saltchars = string.letters + string.digits + './' >>> salt = random.choice(saltchars) + random.choice(saltchars) Note that other ASCII characters are accepted in the salt, but the results may not be the same as other versions of crypt. In particular, '_', '$1' and '$2' do not select alternative hash algorithms such as the extended passwords, MD5 crypt and Blowfish crypt supported by the OpenBSD C library. |
|
|||
__credits__
|
_SPtrans
|
_skb
|
_con_salt
|
_cov_2char
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sat Aug 16 12:16:57 2008 | http://epydoc.sourceforge.net |