-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencryption.py
More file actions
37 lines (25 loc) · 841 Bytes
/
encryption.py
File metadata and controls
37 lines (25 loc) · 841 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
29
30
31
32
33
34
35
36
37
import time
current_time = time.strftime("%H:%M:%S")
print(current_time)
hr = int(time.strftime("%H"))
min = int(time.strftime("%M"))
sec = int(time.strftime("%S"))
#____________________________________________________________
alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
usr_txt = input("Enter the text to Encrypt: ")
encryption_key = (hr * (min + sec))
#encryption
print("Encryption ley: ",encryption_key)
results = []
for letter in usr_txt:
if letter in alpha:
index = alpha.index(letter) +1
results.append(index * encryption_key)
print (results)
#decryption
decrypted_txt = ""
for value in results:
original_index = value // encryption_key
decrypted_txt += alpha[original_index -1]
print(decrypted_txt)
#____________________________________