-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencrypt.py
48 lines (42 loc) · 1.01 KB
/
encrypt.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
48
# encrypting messages
def verif(x: str):
for i in x:
if i.islower() != True:
return False
return True
def esp(x: str):
r = ""
for i in range(len(x)):
r += x[i] + " "
x = r[:len(r)-1]
return x
def rinput():
msg = input("Enter a message: ")
while verif(msg) == False:
msg = input("Enter a message: ")
return msg
def rinput2():
chle = input("Enter The message N2: ")
while verif(chle) == False or len(msg) != len(chle):
chle = input("Enter The message N2: ")
return chle
def crypt(msg,chle):
mcrypt = ""
for i in range(len(msg)):
k = abs(ord(msg[i]) - ord(chle[i]))+1
oa = chr(97 + k - 1)
mcrypt +=oa
mcryptv = esp(mcrypt)
return mcryptv
def diplay(msg, chle, mcryptv):
msg2 = esp(msg)
chle2 = esp(chle)
print(" " + msg2)
print(" " + chle2)
print(" " + mcryptv)
msg = rinput()
chle = rinput2()
esp(msg)
esp(chle)
mcryptv = crypt(msg,chle)
diplay(msg, chle, mcryptv)