-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathREADME.txt
More file actions
67 lines (50 loc) · 1.55 KB
/
README.txt
File metadata and controls
67 lines (50 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Python PKCS#5 v2.0 PBKDF2 Module
--------------------------------
This module implements the password-based key derivation function, PBKDF2,
specified in `RSA PKCS#5 v2.0 <http://www.rsa.com/rsalabs/node.asp?id=2127>`_.
Example PBKDF2 usage
====================
::
from pbkdf2 import PBKDF2
from Crypto.Cipher import AES
import os
salt = os.urandom(8) # 64-bit salt
key = PBKDF2("This passphrase is a secret.", salt).read(32) # 256-bit key
iv = os.urandom(16) # 128-bit IV
cipher = AES.new(key, AES.MODE_CBC, iv)
# ...
Example crypt() usage
=====================
::
from pbkdf2 import crypt
pwhash = crypt("secret")
alleged_pw = raw_input("Enter password: ")
if pwhash == crypt(alleged_pw, pwhash):
print "Password good"
else:
print "Invalid password"
Example crypt() output
======================
::
>>> from pbkdf2 import crypt
>>> crypt("secret")
'$p5k2$$hi46RA73$aGBpfPOgOrgZLaHGweSQzJ5FLz4BsQVs'
>>> crypt("secret", "XXXXXXXX")
'$p5k2$$XXXXXXXX$L9mVVdq7upotdvtGvXTDTez3FIu3z0uG'
>>> crypt("secret", "XXXXXXXX", 400) # 400 iterations (the default for crypt)
'$p5k2$$XXXXXXXX$L9mVVdq7upotdvtGvXTDTez3FIu3z0uG'
>>> crypt("spam", iterations=400)
'$p5k2$$FRsH3HJB$SgRWDNmB2LukCy0OTal6LYLHZVgtOi7s'
>>> crypt("spam", iterations=1000) # 1000 iterations
'$p5k2$3e8$H0NX9mT/$wk/sE8vv6OMKuMaqazCJYDSUhWY9YB2J'
Resources
=========
Homepage
https://www.dlitz.net/software/python-pbkdf2/
Source Code
https://github.com/dlitz/python-pbkdf2/
PyPI package name
`pbkdf2 <http://pypi.python.org/pypi/pbkdf2>`_
License
=======
MIT