-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpriyanshCipher.py
36 lines (29 loc) · 1.33 KB
/
priyanshCipher.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
class CustomCipher:
cipherText = []
plainText = []
def encryptMessage(self, plain_text):
for character in plain_text:
cipherTextChar = chr(ord(character) * len(plain_text))
self.cipherText.append(cipherTextChar)
return self.cipherText
def decryptMessage(self, cipher_text):
for character in cipher_text:
plainTextChar = chr(ord(character)//len(cipher_text))
self.plainText.append(plainTextChar)
return self.plainText
cipher = CustomCipher()
choice = int(input("What would you like to do?\n1. Encrypt Message\n2. Decrypt Message\n3. Exit\n"))
while choice != 3:
if choice == 1:
plain_text = input("Enter text to encrypt:\n")
cipher_text = cipher.encryptMessage(plain_text)
print("Ciphertext = ",cipher_text)
choice = int(input("What would you like to do?\n1. Encrypt text\n2. Decrypt text\n3. Exit\n"))
elif choice == 2:
cipher_text = input("Enter text to decrypt:\n")
plain_text = cipher.decryptMessage(cipher_text)
print("Plaintext = ",plain_text)
choice = int(input("What would you like to do?\n1. Encrypt text\n2. Decrypt text\n3. Exit\n"))
else:
print("Bad Input")
choice = int(input("What would you like to do?\n1. Encrypt text\n2. Decrypt text\n3. Exit\n"))