-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.py
More file actions
28 lines (25 loc) · 829 Bytes
/
Program.py
File metadata and controls
28 lines (25 loc) · 829 Bytes
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
from AESAlgorithm import AESAlgorithm
from Crypto.Random import get_random_bytes
from Crypto.Util import number
import random
import hashlib
import datetime
from ExpirationDate import ExpirationDate
key = get_random_bytes(16) # 16 bytes key for AES-128
aes = AESAlgorithm(key)
plaintext = 'Hello, world!'
c = aes.encrypt(plaintext)
print("Ciphertext:", c.ciphertext)
print("Nonce:", c.nonce)
decrypted_text = aes.decrypt(c)
print("Decrypted text:", decrypted_text)
raw_decrypted_text = aes.raw_decrypt(c.ciphertext, c.nonce)
print("Decrypted text:", raw_decrypted_text)
print(number.getPrime(20))
print(type(eval("900")))
sa = random.randint(10, 1000)
print(sa)
num = 261328
print(num)
print(hashlib.sha256(num.to_bytes(16,'big')).digest()[:16])
expdate = ExpirationDate(datetime.datetime.now(), 1) # key expires after 1 day