a=input("Enter the msg: ")
ct=[]
pt=[]
y=2
x=0
key=0
z=3
k=0
for i in a:
key=int(2*x+3*y+z)
if ord(i)>=97 and ord(i)<=122:
d=(((ord(i)+key)-97)%26)+97
ct.append(chr(d))
elif ord(i)>=62 and ord(i)<=90:
d=(((ord(i)+key)-62)%26)+62
ct.append(chr(d))
else:
ct.append(i)
x=x+1
key=0
print ("\nEncrypted Data")
str1 = ''.join(ct)
print (str1)
for i in ct:
key=2*k+3*y+z
if ord(i)>=97 and ord(i)<=122:
d=(((ord(i)-key)-97)%26)+97
pt.append(chr(d))
elif ord(i)>=62 and ord(i)<=90:
d=(((ord(i)-key)-62)%26)+62
pt.append(chr(d))
else:
pt.append(i)
key=0
k=k+1
print ("\nDecrypted Data")
str2 = ''.join(pt)
print (str2)
ct=[]
pt=[]
y=2
x=0
key=0
z=3
k=0
for i in a:
key=int(2*x+3*y+z)
if ord(i)>=97 and ord(i)<=122:
d=(((ord(i)+key)-97)%26)+97
ct.append(chr(d))
elif ord(i)>=62 and ord(i)<=90:
d=(((ord(i)+key)-62)%26)+62
ct.append(chr(d))
else:
ct.append(i)
x=x+1
key=0
print ("\nEncrypted Data")
str1 = ''.join(ct)
print (str1)
for i in ct:
key=2*k+3*y+z
if ord(i)>=97 and ord(i)<=122:
d=(((ord(i)-key)-97)%26)+97
pt.append(chr(d))
elif ord(i)>=62 and ord(i)<=90:
d=(((ord(i)-key)-62)%26)+62
pt.append(chr(d))
else:
pt.append(i)
key=0
k=k+1
print ("\nDecrypted Data")
str2 = ''.join(pt)
print (str2)
Screenshot:
No comments:
Post a Comment