-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecrypt.py
executable file
·33 lines (24 loc) · 903 Bytes
/
decrypt.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
#!/usr/bin/env python
import binascii
from pyssss.PySSSS import decode
from io import StringIO, BytesIO
from cryptography.fernet import Fernet
from internal.password_to_key import password_to_key
if __name__ == "__main__":
nKeys = input("Number of Keys required to recompose the secret: ")
keys = []
for i in range(nKeys):
keys.append(raw_input("Enter Key #%s: "%i))
keyBytes = []
for i in range(nKeys):
str = binascii.unhexlify(keys[i].decode('UTF-8'))
sio = StringIO(str.decode('unicode-escape'))
keyBytes.append(sio)
output = BytesIO()
decode(keyBytes, output)
decoded = output.getvalue().decode('UTF-8')
password = raw_input('Password:')
fernet = Fernet(password_to_key(password))
decrypted_secret = fernet.decrypt(output.getvalue()).decode()
print("Here is the decrypted secret:")
print(decrypted_secret)