-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsgCipher.py
More file actions
55 lines (38 loc) · 1.29 KB
/
msgCipher.py
File metadata and controls
55 lines (38 loc) · 1.29 KB
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
#! usr/bin/python3
"""
This Program encrypts and decrypts messages
"""
import pyperclip
def Cipher():
try:
# mode ="encrypt" # or decrypt
mode = input("Do you want to \" encrypt \" or \" decrypt\" ? >>")
message=input("Insert the Message you want to {} >>".format(mode))
#encrypting and decrypting key
key = int(input("Please insert your {} key >>".format(mode)))
LETTERS= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
translated=''
message= message.upper()
for symbol in message:
if symbol in LETTERS:
num=LETTERS.find(symbol)
if mode=="encrypt":
num=num+key
elif mode=="decrypt":
num=num-key
if num >= len(LETTERS):
num= num- len(LETTERS)
elif num < 0:
num= num + len(LETTERS)
translated= translated + LETTERS[num]
else:
translated=translated + symbol
print("")
print("*****************************************")
print("The {}ed message is: ".format(mode))
print (translated)
pyperclip.copy(translated)
except:
print("Check what you inputted")
Cipher()
Cipher()