-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvanced.py
More file actions
79 lines (58 loc) · 1.81 KB
/
Advanced.py
File metadata and controls
79 lines (58 loc) · 1.81 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
79
import random
def Encryption(val):
key = []
k=0
a=0
val1=""
for i in range(0,5):
k = random.randint(1,10)
key.append(k)
key.append(1)
for i in range(0,len(val)):
a=ord(val[i])
if(a!=32):
if(i%5==1):
a+=key[0]
elif(i%5==2):
a+=key[1]
elif(i%5==3):
a+=key[2]
elif(i%5==4):
a+=key[3]
elif(i%5==0):
a+=key[4]
else:
a+=key[5]
val1=val1+chr(a)
print("Encrypted Message : ",val1)
print("Key for Decryption : ",key)
def Decryption(val,key):
a=0
val1=""
for i in range(0,len(val)):
a=ord(val[i])
if(a!=33):
if(i%5==1):
a-=key[0]
elif(i%5==2):
a-=key[1]
elif(i%5==3):
a-=key[2]
elif(i%5==4):
a-=key[3]
elif(i%5==0):
a-=key[4]
else:
a-=key[5]
val1=val1+chr(a)
print(val1)
value = input("Type your message you want to get encrypted :")
Encryption(value)
msg = input("Type your message you want to get encrypted :")
print("Enter Encryption Key Numbers one by one :")
key = []
v=0
for i in range(6):
v = int(input("Enter Key Number "+str(i+1)+" :"))
key.append(v)
Decryption(msg,key)