Debian Codegraph @

README.txt

raw ◀ ▶
1 Debian patch touch this file
1 Python PKCS#5 v2.0 PBKDF2 Module
2 --------------------------------
3
4 This module implements the password-based key derivation function, PBKDF2,
•5 specified in `RSA PKCS#5 v2.0 <https://datatracker.ietf.org/doc/html/rfc2898>`_.
6 (Note: There is an update `PKCS #5: Password-Based Cryptography Specification
7 Version 2.1 available <https://datatracker.ietf.org/doc/rfc8018/>`_.)
8
9 Example PBKDF2 usage
10 ====================
11
12 ::
13
14 from pbkdf2 import PBKDF2
15 from Crypto.Cipher import AES
16 import os
17
18 salt = os.urandom(8) # 64-bit salt
19 key = PBKDF2("This passphrase is a secret.", salt).read(32) # 256-bit key
20 iv = os.urandom(16) # 128-bit IV
21 cipher = AES.new(key, AES.MODE_CBC, iv)
22 # ...
23
24 Example crypt() usage
25 =====================
26
27 ::
28
29 from pbkdf2 import crypt
30 pwhash = crypt("secret")
31 alleged_pw = raw_input("Enter password: ")
32 if pwhash == crypt(alleged_pw, pwhash):
33 print "Password good"
34 else:
35 print "Invalid password"
36
37 Example crypt() output
38 ======================
39
40 ::
41
42 >>> from pbkdf2 import crypt
43 >>> crypt("secret")
44 '$p5k2$$hi46RA73$aGBpfPOgOrgZLaHGweSQzJ5FLz4BsQVs'
45 >>> crypt("secret", "XXXXXXXX")
46 '$p5k2$$XXXXXXXX$L9mVVdq7upotdvtGvXTDTez3FIu3z0uG'
47 >>> crypt("secret", "XXXXXXXX", 400) # 400 iterations (the default for crypt)
48 '$p5k2$$XXXXXXXX$L9mVVdq7upotdvtGvXTDTez3FIu3z0uG'
49 >>> crypt("spam", iterations=400)
50 '$p5k2$$FRsH3HJB$SgRWDNmB2LukCy0OTal6LYLHZVgtOi7s'
51 >>> crypt("spam", iterations=1000) # 1000 iterations
52 '$p5k2$3e8$H0NX9mT/$wk/sE8vv6OMKuMaqazCJYDSUhWY9YB2J'
53
54
55 Resources
56 =========
57
58 Homepage
59 https://www.dlitz.net/software/python-pbkdf2/
60
61 Source Code
62 https://github.com/dlitz/python-pbkdf2/
63
64 PyPI package name
65 `pbkdf2 <http://pypi.python.org/pypi/pbkdf2>`_
66
67 License
68 =======
69 Copyright (C) 2007-2011 Dwayne C. Litzenberger <[email protected]>
70
71 Permission is hereby granted, free of charge, to any person obtaining
72 a copy of this software and associated documentation files (the
73 "Software"), to deal in the Software without restriction, including
74 without limitation the rights to use, copy, modify, merge, publish,
75 distribute, sublicense, and/or sell copies of the Software, and to
76 permit persons to whom the Software is furnished to do so, subject to
77 the following conditions:
78
79 The above copyright notice and this permission notice shall be
80 included in all copies or substantial portions of the Software.
81
82 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
83 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
84 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
85 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
86 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
87 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
88 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.