-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencrypter.py
More file actions
78 lines (49 loc) · 1.85 KB
/
encrypter.py
File metadata and controls
78 lines (49 loc) · 1.85 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z','a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def caesor(PLAIN_TEXT,SHIFT_NUM,CYPHER_DIRECTION):
end_text = ""
if CYPHER_DIRECTION == "decode":
SHIFT_NUM *= -1
for n in PLAIN_TEXT:
if n in alphabet:
position = alphabet.index(n)
new_position = position + SHIFT_NUM
end_text += alphabet[new_position]
else:
end_text += n
print(f"the {CYPHER_DIRECTION} text is: {end_text}")
go_again = True
while go_again:
direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
text = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))
Shift = shift % 26
from logo2 import logo
print(logo)
caesor(PLAIN_TEXT = text,SHIFT_NUM = Shift, CYPHER_DIRECTION = direction)
restart = input("Would you like to restart? ")
if restart == "no":
go_again = False
#
#
#
#
#def encrypt(PLANE_TEXT,SHIFT_NUM):
# cipher_text = ""
# for n in PLANE_TEXT:
# position = alphabet.index(n)
# new_position = position + SHIFT_NUM
# new_letter = alphabet[new_position]
# cipher_text += new_letter
#
# print(f"the encoded text is:{cipher_text}")
#
#
#def decrypt(PLANE_TEXT,SHIFT_NUM):
# plain_text = ""
# for n in PLANE_TEXT:
# position = alphabet.index(n)
# new_position = position - SHIFT_NUM
# new_letter = alphabet[new_position]
# plain_text += new_letter
#
# print(f"the decoded text is:{plain_text}")