0% found this document useful (0 votes)
11 views12 pages

Ns Record

The document contains various code snippets for different encryption algorithms, including a Caesar cipher, Hill cipher, Diffie-Hellman key exchange, SHA hashing, and RSA encryption. Each section includes prompts for user input and processes for encryption and decryption. The code is written in C and Java, demonstrating basic cryptographic techniques.

Uploaded by

chantiismart030
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)
11 views12 pages

Ns Record

The document contains various code snippets for different encryption algorithms, including a Caesar cipher, Hill cipher, Diffie-Hellman key exchange, SHA hashing, and RSA encryption. Each section includes prompts for user input and processes for encryption and decryption. The code is written in C and Java, demonstrating basic cryptographic techniques.

Uploaded by

chantiismart030
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
You are on page 1/ 12
poiRanee(Caecay cipher) include qinclucled Shing hy |drinclude “include (29) CipherCi)= cipher CiJ - 26, - Print FU'7.c", cipher iJ i oS 5 ot. Paiotf (“laine AFTER DecRypTion :*)5 © scanned with OKEN Scanner forliz0} icleagthy it) FraioCid = cipherCt)- Keg; itLisupper Cipher CiI) 22 (plain Ci] ae )) Plan Ct) = plain Ci} 1265 Vliclower cipher Ci OR (plain CJ" 6): Print (°C, plain Ci) y 5 gerchor, Enter the plain text shello Enter the key value: 3 Plain! “TEXT: hell6 ENcRYPTED TEXT + choo AFTER DECRYPTION hello ” Program (Hill cipher) Wr owy wy # include <¢tdiosh> ; Hinclude < Conioh> tH Include int main) - unsigned Ink A033 2 8$¢. 24 18 sw tetna. $29.17 8 © scanned with OKEN Scanner F Junsigned Ink bOI $95,104, fa1,9,01% fat ij) by unsigned int Mol, d lr], chav mg 000]; | cKO} Pain enter plain bert \n”); scan CP S*ymeg) 1€71)19,333,| for liz0 i £8tvlenCmey) jit) z eLiJ=msq LiJ-65; Print Cr cb” etig) 5 3 forliz04 iA35 it +) t | £70; ‘ : For (j205)<3 jt) E . \ beba(aciOl #cCjy; | 3 Alijztr26, forlico; ics jit) Paint FC" 7. 0", Agi 5 JPotin FU" (a Brerypled Cipher Tent *, | for (}=05983 jj rt) pee eR ti nO RE OTT TEN LE NT BET RC tu £etx(bi) J *4 Gd) 5 © scanned with OKEN Scanner T. a - : SS I¢ CiJab1-26; [3 ; ipstint( Cn Deerypted Cipher Text *)s [fa liro, 123; it) | Print he, cli) +65) 5 | getchO; | Achan 0; a ‘ [3 = | ceeer: | | Entey plain text | ACT | Orin \ Encrypted cipher Teat : pot | Decrypted cipher Text: A cT | © scanned with OKEN Scanner : PROGRAM (DéFFie - Hellman key Rashange) q wn H include estdio-hy tt include ZConio.hy long, long int power (int a, ‘ long long int +3 | Fiber) ‘| veturn a; ‘int by int mod) |e power (a, bla iMod) j iflw7.9 =20) | FEU (EFL) y mod ; long int Glouleteker lint a int 4 fat) t yelurn power a%)n) ; 5 void main() £L | f ne, 91%) 94rd; || ctseru; )) || Printf L’Erifer the values gn 4 93"); | Scand bd”, 2a, 09); ‘ Print Enter the value OX fer the first person :*); | || Sanh'7d", 2; | 11] 9 powerlg ain) 5 Drink" Enter the value %Y bo she Second person”); Seank CHa" 94) 5 be powet (9,4,n) ; i » nye Print Key for the frst person aye \et poser) © scanned with OKEN Scanner 1 {aoe =} ined Print fC Key fir the Second yrersen bo: tl \e?, ead yan) getchl)s ‘ l3 | | OvTeuT: Enter Finck prime number: | Enley anether prime number Enter the value o, nand y: 1 9 Enter the value 4% bor the fist person: & Enley the value o] 4 for the secmd person: 5° Key fov the first pets to: I Key for the Second person to: | Peniran | Gecure on Algorithm) Import Java: Security. 4; | Public. class SHAL ¢ | Public Static void main( Shing ty a) z Bye Message Digest mol = Mew i i Guat, “IPI Digest gettavtnce Systen-ouk-printly e Syslem cub: prlally Sting put = ° iy ee Gnpul get Bytes lo); | byte cy output = ma: digert (5) Provider -“tmd. Jetprovidert )) ; TANG = amd tasting. 9); he © scanned with OKEN Scanner casas a RO eo pee System -out prtintlol sa | (\" He inoul-t* \") = Hbyley | Totter Coutpul Ys ‘input = “abe”; _|marupdate Unput get Byles. 9), Output: md-digest Or; Spleen “oul paiat In SHAT UC" 4 apt #N") "aby Totter (output) Anput> “ab ede Fqh\jkl mnopanstuvny 5” mavupdate Unpuk - gek Bytes 0); Output = md paiintty (> i Splen out - print c) j System Out paintln US| CS + inpuk "(Jet bojles Tot) (output) ; | Systin out printin C5 3 tah (Exception ¢) & Systern. out: printin(" Exception" 42) ; i a \ i ; | Public Stake String bytes Totten CbytetIb) j ee headigit C92 VO) Ns 234 44/589), 24 RB, ‘Cy rer 3, Sting Buffer. buf=new String Bufferc ) ; Forint 0; 44) § oxotJ); buf-append Chex Digit Cb cj Ju ox ob); Yohum bubs tsbigd); 5 \ 3 © scanned with OKEN Scanner i +_——————————— HL! ovTpuTy } FE 4H C Hi SHAL (°") = DA 34 A3EE SE bgUB0p3 255 BFEF ISG) 0134 0A F090709 SHA (Yabo) = A1993E 36440 691648 3615417 ( 950C26C9CD00310 { SHA L Cavedetghijktmnop-vrstuvwry3 “je { 320loc7 BF CFI6SA OCACU CE3q Falacayaud i 03A 341 | Fin A} | RSA OGRAM : (wi iphey ) PROGRAM : (wiqhthe cipher Finclude # include ¢ shing-h> long ink 5 Prank, Heyy Cd, ae dep cies j tie en) \) Chat m9 Elev}, int Prime (tong int) « Hyoid Cec); Lo © scanned with OKEN Scanner int CA (tong ial); Voiel encrypt), long Voiel decrypt 4 Vosel main o> t POIVs cre D5 Paint ("Ya enter ict prime numbet \n") Scanf Cyd”, Rp); Flag = Prime (9), 1Flflag-20) & Paint Clntneng input la"); Jetch0r, 3 Paint f("\n Enter another prime numbet \n"), Stank Ud” Bad; | flags prime La); | IF (Cag =-oltp== al) § | Patntt(*\n waong input \s"), | JetchO 5 3 | PAnIE( Yacketey message\n") | | FeiushCstdind, Scank (*y. Ss", m4); fos (iso; mgt) += Nott; itr) mei) Femsg Ci) | ne Preys, | beb-1)# (ait), | ce QO, a | PATALE [q Possible values 4 ¢ ane d axe \e"); Fos (120) 1 fags Ktr3 3 VFles24) brerk 5 33 tong int CAUlong int wg long int kely whi U1) 2” ke ktt) HF Ukn ~2260) | a Mo © scanned with OKEN Scanner pe Lee Ny Li get ED La SLL return (Kf)? 5 Void encrypt O t Long int pe ck, Kege €(oJ,k, Len; feo, Leng = strlen (ms); Painth OA”, cLY)) F | fev (iso; ied 5144) b | £50; for jz 05)S 4 tt) & t= kt CaliliJ ed) 3 ACiJe bn 26) 3 Pxinth (“Mnttnoypted cipher teat: *)j | |for Lisoy tea jit) Paint C7c7 d cije or): JF iso 123 51D E +20) Por Ljros eB sjtt yb Leet CbwWUIAAGD)) 7 CU)- trac) 3 prcatt CWBeenypated Cipher Text :")5 || For lize y ies y itt) Patt Cue’, cLij tes) 5 gJetchO; Achan Oj 3 y A. Tents first Pure number F another Prime numbex 13 Ente message hetlo Fae © scanned with OKEN Scanner 2 Grerypted Cipher teu na 888 ted ciphey dont = hello lithe Recn | | | | | | | © scanned with OKEN Scanner

You might also like