-
Notifications
You must be signed in to change notification settings - Fork 2
/
Monoalphabetic.py
46 lines (30 loc) · 1.05 KB
/
Monoalphabetic.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
41
42
43
44
45
46
def mono():
plaintext_small = "abcdefghijklmnopqrstuvwxyz"
#key_small = input("Enter 26 char key for small char: - ")
plaintext_cap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#key_cap = input("Enter 26 char key for cap char: - ")
key_small = "defghijklmnopqrstuvwxyzabc"
key_cap = "GHIJKLMNOPQRSTUVWXYZABCEDF"
leng_small = len(key_small)
leng_cap = len(key_cap)
final = ""
msg = input("Enter msg to encrypt: - ")
leng = len(msg)
count = 0
while count != leng:
if msg[count].isupper():
count1 = 0
while plaintext_cap[count1] != msg[count]:
count1 = count1 + 1
final = final + key_cap[count1]
elif msg[count].islower():
count1 = 0
while plaintext_small[count1] != msg[count]:
count1 = count1 + 1
final = final + key_small[count1]
else:
final = final + msg[count]
count = count + 1
return final
final = mono()
print(final)