-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmonoalp.py
47 lines (44 loc) · 1012 Bytes
/
monoalp.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
monoalpha_cipher = {
'a': 'X',
'b': 'D',
'c': 'G',
'd': 'S',
'e': 'Z',
'f': 'A',
'g': 'N',
'h': 'Y',
'i': 'O',
'j': 'B',
'k': 'T',
'l': 'M',
'm': 'J',
'n': 'C',
'o': 'E',
'p': 'V',
'q': 'F',
'r': 'H',
's': 'K',
't': 'W',
'u': 'P',
'v': 'L',
'w': 'Q',
'x': 'U',
'y': 'R',
'z': 'I',
' ': ' ',
}
inverse_monoalpha_cipher = {}
for key, value in monoalpha_cipher.iteritems():
inverse_monoalpha_cipher[value] = key
mode = raw_input("Do you want to Encrypt or Decrypt ?")
message = raw_input("Please enter the message : ")
if mode == "encrypt":
encrypted_message = []
for letter in message:
encrypted_message.append(monoalpha_cipher.get(letter,letter))
print(''.join(encrypted_message))
elif mode == "decrypt":
decrypted_message = []
for letter in message:
decrypted_message.append( inverse_monoalpha_cipher.get(letter,letter))
print(''.join( decrypted_message ))