0% found this document useful (0 votes)
20 views8 pages

Shhail Ahmad

Uploaded by

arpit964822
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views8 pages

Shhail Ahmad

Uploaded by

arpit964822
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

NOIDA INSTITUTE OF ENGINEERING AND

TECHNOLOGY GREATER NOIDA-201306


(An Autonomous Institute under affiliation of AKTU)
School of Computer Sciences & Engineering in
Emerging Technologies

B. Tech (ARTIFICIAL INTELLIGENCE)

LAB MANUAL
of
Introduction to Cryptography Lab (ACS0451)
(4th Semester)

Affiliated to Dr. A.P.J Abdul Kalam Technical University, Uttar Pradesh, Lucknow

Submitted to: submitted by:


MS Monika Mehra Shahil Ahmad
Praveen Kumar Tomar 2201331520157
INDEX

Course Code ACSAI0453


Course Title Introduction to Cryptography Lab
Sr. No. Name of Experiment Date Remark
1 Implementing Shift Cipher

2 Implementing Polyalphabetic Substitution Cipher.

3. Implementing Caesar Cipher

4 Implementing Additive Cipher (Mono-alphabetic Substitution


Cipher)
5 Implementing Multiplicative Cipher (Mono-alphabetic Substitution
Cipher)
6 Implementing Affine Cipher (Mono-alphabetic Substitution Cipher)

7 Implementing Playfair Cipher

8 Implementing Vernam Cipher.

9 Implementing Symmetric Key Encryption Standards (DES)

10 Implementing Symmetric Key Encryption Standards (AES)


PROGRAM 1 PROGRAM TO IMPLEMENT SHIFT CIPHER
a=input("Enter the statement you want to encode: ")
for i in a:
s=ord(i)
if s==32:
j=chr(s)
elif s==65:
j=chr(108)
elif s==66:
j=chr(109)
elif s==67:
j=chr(122)
elif s==68:
j=chr(97)
elif s==69:
j=chr(98)
elif s==70:
j=chr(100)
elif s==71:
j=chr(99)
elif s==72:
j=chr(103)
elif s==73:
j=chr(110)
elif s==74:
j=chr(102)
elif s==75:
j=chr(101)
elif s==76:
j=chr(104)
elif s==77:
j=chr(105)
elif s==78:
j=chr(117)
elif s==79:
j=chr(106)
elif s==80:
j=chr(115)
elif s==81:
j=chr(119)
elif s==82:
j=chr(107)
elif s==83:
j=chr(121)
elif s==84:
j=chr(118)
elif s==85:
j=chr(120)
elif s==86:
j=chr(111)
elif s==87:
elif s==88:
j=chr(113)
elif s==89:
j=chr(116)
elif s==90:
j=chr(112)
print(j,end="")

a=input("Enter the statement you want to decode: ")


for i in a:
s=ord(i)
if s==32:
j=chr(s)
elif s==108:
j=chr(65)
elif s==109:
j=chr(66)
elif s==122:
j=chr(67)
elif s==97:
j=chr(68)
elif s==98:
j=chr(69)
elif s==100:
j=chr(70)
elif s==99:
j=chr(71)
elif s==103:
j=chr(72)
elif s==110:
j=chr(73)
elif s==102:
j=chr(74)
elif s==101:
j=chr(75)
elif s==104:
j=chr(76)
elif s==105:
j=chr(77)
elif s==117:
j=chr(78)
elif s==106:
j=chr(79)
elif s==115:
j=chr(80)
elif s==119:
j=chr(81)
elif s==107:
j=chr(82)
elif s==121:
j=chr(83)
elif s==118:
j=chr(84)
elif s==120:
j=chr(85)
elif s==111:
j=chr(86)
elif s==114:
j=chr(87)
elif s==113:
j=chr(88)
elif s==116:
j=chr(89)
elif s==112:
j=chr(90)
print(j,end="")
PROGRAM 2 PROGRAM TO IMPLEMENT POLYALPHABETIC SUBSTITUTION CIPHER (ONE TIME
PAD CIPHER)
x=int(input("Enter the number through which you want to encrypt the message"))
s=input("Enter the statment")
c=""
n=""

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)

s=input("Enter the text")


k=input("Enter the Key")
b=[]
z=[]
add=[]
f=""
for i in s:
l=ord(i)
l=l-65
b.append(l)
print(b)
for j in k:
m=ord(j)
m=m-97
z.append(m)
print(z)

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

message = input("Enter the message:")


print("Cipher:", encrypt(message, 3))

# 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

cipher = input("Enter the cipher:")


print("Message: ", decrypt(cipher, 3))

You might also like