Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
55 lines (45 loc) · 2.2 KB

File metadata and controls

55 lines (45 loc) · 2.2 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
from . import pypbkdf2
from CryptoPlus.Hash import SHA as SHA1, HMAC
__all__ = ['new']
def new(passphrase, salt, iterations=1000, digestmodule=SHA1, macmodule=HMAC):
"""PKCS#5 v2.0 Password-Based Key Derivation
passphrase = the passphrase, supplied as a raw string, to make a key from
salt = salt as raw string
iterations = amount of iterations (default = 1000)
digestmodule = digest function to use, supply as module
example: python_SHA from CryptoPlus.Hash
default: SHA1
macmodule = mac function to use, supply as module
example: HMAC from CryptoPlus.Hash
default: HMAC
=> macmodule & digestmodule construct the pseudorandom function
=> by default: HMAC-SHA1
Examples: (from: http://www.ietf.org/rfc/rfc3962.txt)
==========
>>> from CryptoPlus.Hash import python_PBKDF2
>>> passphrase = b"password"
>>> salt = b"ATHENA.MIT.EDUraeburn"
>>> iterations = 1
>>> hasher = python_PBKDF2.new(passphrase,salt,iterations)
>>> hasher.hexread(16)
'cdedb5281bb2f801565a1122b2563515'
>>> passphrase = b"password"
>>> salt = b"ATHENA.MIT.EDUraeburn"
>>> iterations = 1200
>>> hasher = python_PBKDF2.new(passphrase,salt,iterations)
>>> hasher.hexread(32)
'5c08eb61fdf71e4e4ec3cf6ba1f5512ba7e52ddbc5e5142f708a31e2e62b1e13'
>>> passphrase = b"X"*64
>>> salt = b"pass phrase equals block size"
>>> iterations = 1200
>>> hasher = python_PBKDF2.new(passphrase,salt,iterations)
>>> hasher.hexread(32)
'139c30c0966bc32ba55fdbf212530ac9c5ec59f1a452f5cc9ad940fea0598ed1'
>>> passphrase = b"X"*65
>>> salt = b"pass phrase exceeds block size"
>>> iterations = 1200
>>> hasher = python_PBKDF2.new(passphrase,salt,iterations)
>>> hasher.hexread(32)
'9ccad6d468770cd51b10e6a68721be611a8b4d282601db3b36be9246915ec82a'
"""
return pypbkdf2.PBKDF2(passphrase, salt, iterations, digestmodule, macmodule)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.