-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
40 lines (28 loc) · 834 Bytes
/
run.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
34
35
36
37
38
39
40
from encrypt import pad, to_hex, encrypt
from decrypt import rmpad, to_str, decrypt
plain = input("Enter Plain Text: ")
key = input("Enter Key: ")
# print("Plain Text: ", plain)
# print("Key: ", key)
print("\n-------------------- Encryption ----------------------\n")
inp = to_hex(pad(plain))
key = to_hex(pad(key))[0]
ct = []
for block in inp:
ct.append(encrypt(block, key))
encrypted_text = ""
for block in ct:
encrypted_text += to_str(block)
print("\n")
print("Encrypted Text: ", encrypted_text)
print("\n")
print("\n-------------------- Decryption ----------------------\n")
dt = []
for block in ct:
dt.append(decrypt(block, key))
print()
print("\n---------------------- Result ------------------------\n")
final = ""
for block in dt:
final += to_str(block)
print("Decrypted Text: ", rmpad(final))