-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShift Encryption in python.py
67 lines (50 loc) · 1.46 KB
/
Shift Encryption in python.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
''' Anmol wants to encrypt the message which is to be sent to his business partner.Binamol, so he shifts every alphabet by X positions in forward direction and he adds Y ro every number in the message.
Given string value M of the message and the values of X and Y, the program must print the encrypted message E.
->All alphabets will be lowercase.
->Spaces and special characters in message M should be reproduced as such in the encrypted message E.
Example 1:
Input:
call me at 10p.m
2
1
Output:
ecnn og cv 21r.o
Program:
'''
import string
words = input()
x = int(input())
y = input()
alph = list(string.ascii_lowercase)
num = ["0","1","2","3","4","5","6","7","8","9"]
out = []
e = 0
k = ""
for i in range(len(words)):
for j in range(len(alph)):
if words[i] == alph[j]:
e = 0
e = j + x
if e < 25:
out.append(alph[e])
else:
e = e - 26
out.append(alph[e])
if words[i] == " " or words[i] == ".":
out.append(words[i])
else:
for l in range(len(num)):
#print(words[i],num[l])
if words[i] == num[l]:
#print(words[i])
k = words[i]
k = int(k)
#words[i] = int(words[i])
#print(k)
e = k + int(y)
out.append(str(e))
s = ""
for i in out:
s += i
#print(s)
print(s)