-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAES256-Basic-Examples.py
More file actions
44 lines (30 loc) · 2.31 KB
/
AES256-Basic-Examples.py
File metadata and controls
44 lines (30 loc) · 2.31 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
44
import AES256_Basic_Functions
IV = 1234567890123456 #IV in int form
IV = IV.to_bytes(16, 'big') #IV in byte form
# ---AES with set IV returning encrypted message in hex form---
encrypted_message = AES256_Basic_Functions.AES_encrypt_hex("This is plain text", "Secure password", IV)
print(encrypted_message, "\t\t\t\t- Set IV encrypted message in hex form")
# ---AES with random IV returning encrypted message in hex form---
encrypted_message, Random_IV = AES256_Basic_Functions.AES_encrypt_hex("This is plain text", "Secure password")
print(encrypted_message, "\t\t\t\t- Random IV encrypted message in hex form")
print(Random_IV, "\t\t- Random IV")
# ---Decrypting with encrypted message in hex form--
print(AES256_Basic_Functions.AES_decrypt_hex(encrypted_message, "Secure password", Random_IV), "\t\t\t\t\t\t- Decrypted text\n")
# ---AES with set IV returning encrypted message in base64 form---
encrypted_message = AES256_Basic_Functions.AES_encrypt_base64("This is plain text", "Secure password", IV)
print(encrypted_message, "\t\t\t\t\t- Set IV encrypted message in base64 form")
# ---AES with random IV returning encrypted message in base64 form---
encrypted_message, Random_IV = AES256_Basic_Functions.AES_encrypt_base64("This is plain text", "Secure password")
print(encrypted_message, "\t\t\t\t\t- Random IV encrypted message in base64 form")
print(Random_IV, "\t\t- Random IV")
# ---Decrypting with encrypted message in base64 form--
print(AES256_Basic_Functions.AES_decrypt_base64(encrypted_message, "Secure password", Random_IV),"\t\t\t\t\t\t- Decrypted text\n")
# ---AES with set IV returning encrypted message in byte form---
encrypted_message = AES256_Basic_Functions.AES_encrypt_raw("This is plain text", "Secure password", IV)
print(encrypted_message,"\t\t- Set IV encrypted message in byte form")
# ---AES with random IV returning encrypted message in byte form---
encrypted_message, Random_IV = AES256_Basic_Functions.AES_encrypt_raw("This is plain text", "Secure password")
print(encrypted_message, "\t\t- Random IV encrypted message in byte form")
print(Random_IV, "\t\t- Random IV")
# ---Decrypting with encrypted message in byte form--
print(AES256_Basic_Functions.AES_decrypt_raw(encrypted_message, "Secure password", Random_IV), "\t\t\t\t\t\t- Decrypted text\n")