-
Notifications
You must be signed in to change notification settings - Fork 2
/
slowkdf_cut_32.py
40 lines (27 loc) · 1023 Bytes
/
slowkdf_cut_32.py
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
#!/usr/bin/python3
import scrypt
import binascii
import getpass
from hashlib import sha512
def SlowKDF(password, salt, i):
digest = password
for counter in range(i):
print ("Iteration %s from %s..." % (counter+1, i) )
digest = scrypt.hash(digest, salt, N = 1048576, r = 8, p = 1, buflen = 128)
return digest
mypass = getpass.getpass("Passphrase: ")
if mypass != getpass.getpass("Repeat passphrase: "):
print ("ERROR: Passwords do not match.")
quit()
if mypass != getpass.getpass("Repeat passphrase (again): "):
print ("ERROR: Passphrases do not match.")
quit()
mysalt = input("Salt: ")
mynumber = int(input("Number of iterations: "))
mypass = mypass.encode()
mysalt = mysalt.encode()
mydigest = SlowKDF(mypass, mysalt, mynumber)
mydigest_v2 = sha512(mypass+mysalt+mydigest).digest()
base64_v2 = binascii.b2a_base64(mydigest_v2).decode("utf-8")
base64_v2_cut_32 = base64_v2[:32]
print ("\n\nVersion 2 digest in base64 format, first 32 characters:", base64_v2_cut_32)