2017-06-14 10:21:31 +08:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import getpass
|
|
|
|
|
2017-09-06 09:22:16 +08:00
|
|
|
import scrypt # pip install scrypt
|
|
|
|
import binascii
|
2017-08-14 07:43:33 +08:00
|
|
|
|
2017-06-14 10:21:31 +08:00
|
|
|
password1 = getpass.getpass()
|
|
|
|
|
|
|
|
print('Repeat the same password:')
|
|
|
|
|
|
|
|
password2 = getpass.getpass()
|
|
|
|
|
|
|
|
if password1 == password2:
|
2017-09-06 09:22:16 +08:00
|
|
|
# salt is constant
|
|
|
|
salt = "dc73b57736511340f132e4b5521d178afa6311c45e0c25e6a9339038507852a6"
|
2017-06-14 10:21:31 +08:00
|
|
|
|
2017-09-06 09:22:16 +08:00
|
|
|
hashed = scrypt.hash(password=password1,
|
|
|
|
salt=salt,
|
|
|
|
N=16384,
|
|
|
|
r=16,
|
|
|
|
p=1,
|
|
|
|
buflen=32)
|
|
|
|
|
|
|
|
print('Generated password hash:')
|
|
|
|
print(binascii.hexlify(hashed))
|
2017-06-14 10:21:31 +08:00
|
|
|
else:
|
|
|
|
print('Entered passwords are not identical!')
|