-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncryptedDocsAES.py
More file actions
43 lines (26 loc) · 1.05 KB
/
EncryptedDocsAES.py
File metadata and controls
43 lines (26 loc) · 1.05 KB
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
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
header = "header"
#data should not be visible in code
class Main():
def __init__(self, data):
data = bytes(data, 'utf8')
#Randomly generated key, set to fixed key for constant value
key = get_random_bytes(32)
print(key)
#instantiate cipher object
cipher = AES.new(key, AES.MODE_EAX)
cipher.update(data)
self.encryptData = cipher.encrypt(data)
print('This is the encrypted data')
print(self.encryptData)
#this should initialize update?
self.next = cipher.update(self.encryptData)
cipher.update(self.encryptData)
self.decryptData = cipher.decrypt(self.encryptData)
print('This is the decrypted data')
print(self.decryptData)
#Encrypt data using AES, generating ciphertext and tag for verification
#ciphertext, tag = cipher.encrypt_and_digest(data)
data = Main('here is some data')
print(Main.encryptData)