Skip to content

Commit 9e9fbdd

Browse files
committed
Python Cipher Text example
1 parent 6e1df3b commit 9e9fbdd

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Programs/P40_CipherText.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,8 @@
44
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
55
LETTERS = LETTERS.lower()
66

7-
def main():
8-
message = str(input('Enter your message: '))
9-
key = int(input('Enter you key [1 - 26]: '))
10-
choice = input('Encrypt or Decrypt? [E/D]: ')
11-
12-
if choice.lower().startswith('e'):
13-
print(encrypt(message, key))
14-
else:
15-
print(decrypt(message, key))
16-
177
def encrypt(message, key):
8+
''' This function lets you to encrypt your message based on a key '''
189
encrypted = ''
1910
for chars in message:
2011
if chars in LETTERS:
@@ -27,6 +18,7 @@ def encrypt(message, key):
2718
return encrypted
2819

2920
def decrypt(message, key):
21+
''' This function lets you to decrypt your message based on a key '''
3022
decrypted = ''
3123
for chars in message:
3224
if chars in LETTERS:
@@ -38,9 +30,20 @@ def decrypt(message, key):
3830

3931
return decrypted
4032

33+
def main():
34+
message = str(input('Enter your message: '))
35+
key = int(input('Enter you key [1 - 26]: '))
36+
choice = input('Encrypt or Decrypt? [E/D]: ')
37+
38+
if choice.lower().startswith('e'):
39+
print(encrypt(message, key))
40+
else:
41+
print(decrypt(message, key))
42+
4143
if __name__ == '__main__':
4244
main()
4345

46+
# OUTPUT:
4447
# omkarpathak@omkarpathak-Inspiron-3542:~/Documents/GITs/Python-Programs/Programs$ python P40_CipherText.py
4548
# Enter your message: omkar
4649
# Enter you key [1 - 26]: 2

0 commit comments

Comments
 (0)