Shhail Ahmad
Shhail Ahmad
LAB MANUAL
of
Introduction to Cryptography Lab (ACS0451)
(4th Semester)
Affiliated to Dr. A.P.J Abdul Kalam Technical University, Uttar Pradesh, Lucknow
for i in s:
if i!=" ":
d=ord(i)
d=d+x
d=chr(d)
c=c+d
else:
c=c+i
print("Encrypted message: ",c)
for j in c:
if j!=" ":
k=ord(j)
k=k-x
k=chr(k)
n=n+k
else:
n=n+j
print("Decrypted Message",n)
for a in range(len(b)):
d=b[a]+z[a]
if d>26:
d=d-26
add.append(d)
else:
add.append(d)
print(add)
for e in add:
a=97+e
f=f+chr(a)
print(f)
PROGRAM 3 PROGRAM TO IMPLEMENT CAESAR CIPHER
# Encryption part
def encrypt(message, key):
cipher = ""
for i in message:
if i.isupper():
cipher += chr((ord(i) + key - 65) % 26 + 65)
elif i.islower():
cipher += chr((ord(i) + key - 97) % 26 + 97)
else:
cipher+=" "
return cipher
# Decryption part
def decrypt(cipher, key):
message = ""
for i in cipher:
if i.isupper():
message += chr((ord(i) - key - 65) % 26 + 65)
elif i.islower():
message += chr((ord(i) - key - 97) % 26 + 97)
else:
message+=" "
return message