-
Notifications
You must be signed in to change notification settings - Fork 19
/
AtBash.py
71 lines (56 loc) · 1.74 KB
/
AtBash.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# *********
# -*- Made by VoxelPixel
# -*- For YouTube Tutorial
# -*- https://github.com/VoxelPixel
# -*- Support me on Patreon: https://www.patreon.com/voxelpixel
# *********
def at_encryption():
alpa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
# reversing alphabets of alpa variable
rev_alpa = alpa[::-1]
message = input("Enter message: ").upper();
encry_text = ""
for i in range(len(message)):
if message[i] == chr(32):
encry_text += " "
else:
for j in range(len(alpa)):
if message[i] == alpa[j]:
encry_text += rev_alpa[j]
break
# if
# inner for
# if-else
# for
print("Encrypted Text: {}".format(encry_text))
def at_decryption():
alpa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
# reversing alphabets of alpa variable
rev_alpa = alpa[::-1]
message = input("Enter message: ").upper();
dencry_text = ""
for i in range(len(message)):
if message[i] == chr(32):
dencry_text += " "
else:
for j in range(len(rev_alpa)):
if message[i] == rev_alpa[j]:
dencry_text += alpa[j]
break
# if
# inner for
# if-else
# for
print("Decrypted Text: {}".format(dencry_text))
def main():
choice = int(input("1. Encryption\n2.Decryption\nChoose(1,2): "))
if choice == 1:
print("---Encryption---")
at_encryption()
elif choice == 2:
print("---Decryption---")
at_decryption()
else:
print("Wrong Choice")
if __name__ == "__main__":
main()