Ex.
No:(2
Date: os/o/3023
Caescun cipher
Aim:
inplement Caegan cipher adgorithm for
encphion and decryphon wing e progran
decrgphon
Algorithm :
Step i: Dedane a chanacten aay StrC1oo] .
Step 2: Declane ninteger k koy vauo
in
Step 3: Read the mes age and eey
Step 4: set up a Loop from o to lengtk of
|Step s: check ie the chaacter is alpha or number
ch =(ch- a' +ka 426).26 +^a
) ebe ie he chaeter upp letter
ch (eh- 'A' kay ) 2b t A
ii) ele if the charaeten is a nunben
h= (ch - o' 4key e (o + 1o'
8tep b:
Otheuoihe prunt Mesage.
Finally prìnt the erenypied mesge.
Step &: Set up a for lop fom o to length of sr.
or nunter
check ie the chanacten is alpha bmall
Step q: ijcheck ie the chaacten s lettey
h= (ch-'a'-k +26) 2b +a
seplo i) ele i the chanacten is ugpey ease lette
ch=(ch- 'A'- k +26) . eb + A!
ii) ele p the chanacter s anunbey
yZ4sN ag:e meDeevypt
s ed
eFw¥T mes
:age Erevypted
key the Entei
yz8N encrypt: to
message Enter
a
Output
Step (o. othenwise print as huald Message
step l: Finaly print the Þecngted mesage.
Program:
# include Kstdio. h>
# inelude <stdlib.h
#incude <shingh
inb manC)
chan str Cioo], eh
nt K
prìntf (" Enten a mesage to enerypt
;");
Scanpls" str);
printfl Enten she
Seanp ("d d", sk); int Q= strlen(str);
forl int i=0 i< l; i+4)
ch= stCiJ:
ig Ciclowen Cch)
'a';
ch= Cch- 'a' +k)/ 28 +
else if (isupper (ch))
eh- (ch-'A+*)-24 + 'A';
ch=Cchlo'+ K) 1o +o';
3
3
else
printf "Invalid mesage");
styi}=ch;
Print e" Encrypted meuage : /"s",str).
for(int is0 ,i<l;i++)
ch= strCiJ;
ie (isalhum Cch))
ip (isloweteh))
Cch- a' key +26)- 26 + 'a'3
eh-
ebe ie Cisupper Cch))
Ceh-a'- key t2b) t.26 + 'A';
ch=
else if lis digit (ch))
che(ch-'o'-k+10) to o;
ese
printp ("INalid mesage
sbrCiJ = ch;
3
("oecvypted meuage : s", st);
Printy
3
Tine Viva Total
Problem Tmplementation management
Ci) (5)
Undestonding Coo) (o)
Qo)
Resuf:
Hence Cprogam for inplementahion q4
was
Causan cphen
exeauted
fon eranghion and decgtion
Buecepully d output was Nepied.