0% found this document useful (0 votes)
7 views37 pages

Crypto Lab

lab coded

Uploaded by

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

Crypto Lab

lab coded

Uploaded by

vepil62103
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
—uwdxite__o c_ pro amo Compute. the foltarin ia) —CicD_b ~euclidear Needs : al | 4d Ore Db — Extended _¢ uctidean Method ——— | | i —_Muttt {eatJe Imbene by. extended Euclidean Mettat sl | ee include _3_ — entey choice ’, “invalid choice - . Multiplicative ‘nverse of 3 modulo 2 is 7 first “Value of t and S is: 124 0 pi ___|4¢ include < String. | | | define __MAX_ Msor_ fe, ood | }—Noid_—_eneayptionCchay mers c3,int_key ‘int_iS ae “include _< Stdiorh i |_| fox Geo’ 1 Le sérlentmen) pitt) € if Cmescis to! £6 mew cites ‘2! ) | meso) = mea cid =a! key 20 )# ‘a! 5 | y else if C mest) >= tat 4h mewcid <= *z') to — meutid <(imesci='a' egy Yael a 3 | x) | eine ey) Bienes for (ico ; \< StrlemCmen) j iet) £ “LE Gem ci 9= tq! _\b mescid<='z') { at me.) = _CC men ci) ~'a! = key + 26 Jee) ea’; Base “ Cmencin>='al th mes<2'2 2 | mes ci = C Ceci) ta! buy 426) 120 4°00) Teacher's Signature | | —}———Chat__me [MAx_ MsG-Lew] | ee intl i Putile + sncrgpted fc, * decrypted decry = pe ate fees eye a 7 | —|-_brine c* exvor") « “tnt ks : oe 4 -fges. (mew, MAX_MsoreLeNn , inputfile ) a ‘inputfile > | m espn Cmes, “~n")"] =" \o' - f ana ah Nigzsd, eC 8fecl* ie n= Encey pita file _=_Fopem (“encaypied txt", *w" ) > if “Cemenppiedgiie == Mut )¢ primstCevrov" J Yedum 4 4 | rintt Comcaypird ple» “ts! men | sen es aeons m ge writen to cmeypitd txt hn'); sea fi aoe e decry pied « txt”) Ww euuaige == .NuLL) | | ‘Teacher's Signature | Output oo Y open input file and xead plain text og " CRYPTOGRAPHY” ' plain-text is 4 close file — Enter key ae 1 Open encaypted file and Waite encaypted text dn it which is " HupUrTLWFUND " > =encypted mesane watten to encaypted + txt 4 i wank -to deeyption open dexypted file and wrt yin i& dewpted text foY "HWDUYTLWFUMD" " “ayprography" - J Deeypicd meg — woaliiem to clecuy pred Oct | —|_—for Cink iso ; 1x26; eed Tf CCiek) pages) relumn i; B17 ve —relum =} 3 ; 5 : ; hat flonase Pue*thty = fofem (filename, “O° ) 9 if C£ptr == Nuit) <___brintf C*evor')} as 1 P : ate Cint_iz0; plain-text 12 ‘\o' yet) { | cm eee “rf CisuppexC plaintext) { pees f pute Cty * © plain text cl - ‘a! )) 12 AY |b elseif Cislower Cplain text cin) £ Teacher’ Signature —— - = Date Page No. are HC plain-text 9-=¢ ‘dae + tot L pied: ‘ ee ——— ee Fre C plan tent i, ol 5 4 felose Cepty) |e | ———+ ; a 7 | Tiere = epee filemame, "0": | i4_(qpere= Nu) £ | peint-f Cenoy" )) Cin 0 Spin tak Fae) | ig Cisupper col | it Cisupper Cc phere tert TOL ppt Chine cl phex—text (iJ ~'a)J1 24 : pte; —| _ | | 4 elce iF Cislouer Coipher text cia) £ | ‘ca func C chy -IndexR_* Cipher. eft (= ta! 1.26 + ot, fps ee 4 lee £ - | ‘Teacher's Signature fae Page No, 10 fe (_cipper tex text, oe 7 } i yh (fpty ds - | a | cia | | tint mom cot _| | eh Laem. text | | Chay Ciphex text C100). | “Int keys | | Gointf C emter Plain text_t sy | can Chps" — | brint f C" entex | eat Cyd" ae | enutypt C plain text , ke emckypted txt”); \ 7 ' i So | printf ¢ a commpiete \n") | | « = fopen (emcunpted.tx4" x"); | if ie | | res | t \ | —t is jnt_f=0; ___|__ while = — praetor fog Cpe) { = cor) 4 ipher - text Ci) = " \o foto Cpe) 2 i ‘Teacher's Signature Cc —— Soe i en rie ipler— text» kay" toh) Tie ecepioe coogi aoa y (| xetum_o; a 3 orserhar'e Sionature Enter plain text + CRYPTOIRAPHY €ntey key Zp decrypted mesage EVWRZCMVARBW Will be Written 4 file demmypted- 4xt - Aaayption complete - I] rey pred message opMBDUGPASXM Will be Witten +o emexypeeal: txt enayplon Complete. ik _modSnidere ¢ int «) f ee for. Cint iz 0; icoe; ite) ¢ If Coek)ypr¢ eee Eee Gia ci —text_CiI | aa ao CiD_= Cougs * (plan tent Cl. ='A')iexey2) y 26 + 1A'D > 3 ekce 1 ( islowey ( plaintext UI) £ | [Fhe on pint ct ab aga : Ice — ay cipher text CiJ_s plain .texk ci; + ‘Teacher's Signature bg cine kext sblencplain tet J = 10" 4 pt Copa a Hg “ink Jag 4 —— char * plain-text )_¢ | nt _key indore = ey, hese , eet | | baint{ kuy laesn't exist” ) | peter | 4 | w (int _izo; ciphertext Ci]}='\0' 5 jet) ie | if i. Upper Cipher. text Li) _¢ ;—Plosm text.) = _C CC Celpher text Ci) = A! key 2 )n26 26 W-26 J Ty ote ie fna pe e ———_ Ps LCC eiphee tent Ulla tye deat $20.26 T inverse )+/-26 + 'a ¥y else € : a a + = = L 1 a J Plain—text Cs: iJ ee } | Teacher’ Signature nt maine) € Ch? plain text 100], ei phor-text Clad)» dermay plea text; ——int _key Ss ee ; Teacher $s Signature output enter plain text > cryptography enter fint key 2 5 Enter second key + & Encxy pon Cipher-text = spytzampi fry Deayptien . Pin -text = ceybragraphy. [-Pzograms__+o implement _polyalphabetic cipher —_| : zi | & pbk )j int f= 0) I 96 £& encxypt 7 < 23 | encrypt UD == 327 | 2 13 : — | iok_xemovespees_Cchax * plain, int ps) nt_f, Count =o; | forCint_i=0; je ps; ist) t [ if-Cplain cO_} = * ') | Teacher’ Signature [ Expt. No. _ -— ——Plown C count ++) = ploim Ci); | plain tcount J =! \o': | yeti count _ [og Volt generate Table Conor keystr 02, io pea chay baer) inti ki flags 0, * dindy i | —|———cliety = Cint*) cotlsr (26, gizeoftint |): = for (ico jitcess ite) £ | if Couystr cid Je jd | dicty Cheystyd, -97) = 2; | y je 999. Sy | y Ckeo! Kesey eet) | Lf Coiety Cheysty C ea 2)t chicly Ckeyaty CkJ- 97) - a far th Gers) £ | j itt jee for (k=O; kere; ket 4 If Coucty 42220) { i | keyTtiT I = (chav). Cat27j Utts Teacher's Signature Date Expt. No, cet eta seu } a if (jes) £ | fea jee; - | f j=0; | 5394 cea | 4 ay_3ty CI. int pts) $ ____ aja —ubs-5 = | for Cleo < gubsg} ize2) € 1 £ ¢ soci] = = six tist]> xt fo r paid gle Sty Gad 2 tx Cit] = tA! ubS-& +2) } | 14 | str L&ubs-sJ = '\0! if Csubs s-2 [ 20) £ | ee ty (sube-sJ = ‘Jo! | 3 : Se Ned vet A fle Ai 3 | Void search ( chav feyTcs)C9), chay ae charhsyrt_anc7 J | £ finé (43 an if Cazes | asi! en | else if (b22)') | ele te | Teacher's Signature | ___ ete ie Cent Cag a =6)E | owrQJ2i> + axrcalej; Yay | —Woick_enceypt Cchay sty €7., chay keyTCsIts], int ps) ea & int i acu; | for Geo 5 jcpsi drz2) £ if Catols=a@js £ | StrU) = keyT Caco caci+t! )y-S1; Getse if Cac == 4cs)) £ | jje TL amt I-5 1 Ca cI)s Sty G41) =k Cac2dt) 7-5) FaeII y 9 else € . an | | sty Cid = keyTLaco) a3] y SO Gt) = kyl Ca@D Cac]; | HT, 6 7 4 34 = | ks 2 wemovespaces keys SQ | ps = remove spacer (Sp pede pss prepart Csr po) | gene lable Cray, bey TD | 1 Teacher's Signature | i emcruspt CS key ps) Ee — -toupper Gse C ste, ps)j —|—_paint$ C *ciphertert ifs jn” » Sty 2, | for deception | Void _playtaix Decypt Char ate C1, char keyt (7) £ |_|__Void_tolawercaze ( char_plaine2, int_ps) || _—-for Cint_i=o;_j} Scanf—Cy.c yn)", bicheat) palate cn nter_key") scant Chi Peiny", key): a paiotf ce ‘phe text i"): \ | fox. Cint j=0; j=0; ic 7 di +t LA Cpr = StolenCkeyy) ob 208 \ | y . jet Ani = nuypt Croycj])= "A chox_enaypidchaa_= (tn aie I paint C'.e" , enouypted chay > ‘Teacher's Signature |__}—Puintt Center the ciphertext SED 7 oe Sant CC 4\n7" oo ferdnt£ Centon the sey cant (“4 C*\n]" oy PHOeL C" decipnen text 2° ) for int 1=0; y20 5 i< Stem (ciphestert) j jee ire) od if CU7= A&Hen (key )) £ j=o/ 4 nt hift = ouppeh—Ckesgcy2) = ‘a j________| char _ecuypted cha: C Ctoupper Ceipherteat Ci? J~'4!— shiz OG) 226 + Al pring £ Citic", deesuypedehoy ) nt maim c? & int option | while) £. printf C"\n a+ encuypedi pune en Dee pe nes ee eee brintf C "in rrker _youer. Option 2"); "td", Lofton? ia Teacher's Signature Date Page No. _ beak ou 3 exit Co)! break i dlefoult i poinef C'indnvalid chosen") bed RE wxetusn 0% sen ———_—_—— __——— output + Le ency Pt 2+ Decwpt 6 But Enter your option = + enter plauntext 2 cay tography enter key lab cipher cext : NRZATPRRBAHE enter your opH'on 2 enter ciphertext + NRZATPRRBAHZ (ab enter ky Deciphered teat = coypragraphy- entey you open 33 ext > — Expt. No. iiassisseaiassscl —7 — : ————— — we Shey oof eae Saepeeenaaeere _ | ae include < steliot bh 7 ————— — | + include < stoing-h 7 foe eee ed -# _define Mar — | eengt chor Alphobeisek O> “Ancoerumireunaopoestuvxrz", | | | void _encayption Conay_plaimienk C2, chav FST 3 Eg nn sa) Oe ace ea eee | ink m= stoten (key) -for_int i= 0; jem} jer t | |____clphexrextiJ_2_alpnabet.set_C(cptass -'a' + Ceyer7 = A) 261; od, \nt k20 4 for Cint lem; icny Ter) £ ei © iphertext CID = _AlphobetSet CCC plountentOJ 141) + Cpiass sort Kun ='A' J) 1-26 1) keto _ciphexTenct CnJ_=_'\0' fe - | voia _ deoxy pion Cehay “cipneteut C2, char fulliny 2 Teacher's Signature _ cr S 3 | Zz $ fs | __Date Pepe No. [char planted) fT] jp ——ek_0_= Stem CeiphexTere Dd ory Cnt j=o' fcn: i++) {int k = C ciphentent Ci] -!A! )— Cfulleey iD =A!) ; i¢ (k 10! 2 int mama ¥. intf C' “entey key * Sc GS Peete et Diz ang. 4 jot pT length Adolen ( plaisText )" en muy eet tata eet printf C*ciphentect if 5). *s _ciphexTeut i __| txcpy Cfullkers , key) Int tdx = G6; ‘Teacher’ Signature oo. | : = — | | for Cint \ = Strtenckey i j< statem(cepheitent) itt) ¢ | fullkny 19 = ploinTenk Clax “fe ptiong th]: jpdenie % output Enter PlainText = eryptograPh 4 entey key < DE Cipher Eext LBMSDPL RSSTZ deoypted Text » IXE -

You might also like