-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEncryptedFile.py
30 lines (25 loc) · 1.01 KB
/
EncryptedFile.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
import json
import sys
class EncryptedFile:
def __init__(self, filepath):
self._json = self._get_json(filepath)
self.ciphertext = self._json["Crypto"]["ciphertext"]
self.dk_len = self._json["Crypto"]["kdfparams"]["dklen"]
self.n_value = self._json["Crypto"]["kdfparams"]["n"]
self.p_value = self._json["Crypto"]["kdfparams"]["p"]
self.r_value = self._json["Crypto"]["kdfparams"]["r"]
self.salt = self._json["Crypto"]["kdfparams"]["salt"]
self.mac = self._json["Crypto"]["mac"]
def _get_json(self, filepath):
with open(filepath) as f:
json_obj = json.loads(f.read())
return json_obj
if __name__ == "__main__":
enc_file = EncryptedFile(sys.argv[1])
print "ciphertext : ", enc_file.ciphertext
print "dk_len : ", enc_file.dk_len
print "n_value: ", enc_file.n_value
print "p_value: ", enc_file.p_value
print "r_value: ", enc_file.r_value
print "salt: ", enc_file.salt
print "mac: ", enc_file.mac