0% found this document useful (0 votes)
10 views11 pages

NSLab

Cryptography programs

Uploaded by

bjeshmasri
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)
10 views11 pages

NSLab

Cryptography programs

Uploaded by

bjeshmasri
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/ 11
“Generate CRC cade for a given data frame ‘Algorithm ‘1. _Astring af n as appended to the data unit. The length of predetermined divisor iene 1. 2. The newly formed data unit 1. string of n ass appencled to the data unit. The length of predetermined Siieor ie 4. Le. orginal ata + string of as are divided bythe diviza Using. binary division and remainder fs obtained. This remainder isealled CRC. Now, string of 805. ‘appended to data unit is replaced by the CRC remainder (which is also of n bit). The data unit + CCRC is then transmitted to receiver. 3. The receiver en receiving it divides data unit + CRC by the same divisor & checks the remainder. 4. Ifthe remainder of aivision is zero, reeoiver assumes that there 6 no exrar in data and it accepts, {if remainder ts non-zero then there isan ert in dataand receiver rejects. sincdecstco > Wincdecmath i> tincuaecstrng n> ‘oid main) ‘ int ijikmad; shar 3(30}8 (200.300); Pein" ENTER POLYHANOMIAL”); cana}; Prin" ENTER THE FRAME:"); sseanif{"56s",b}; imectien(a) nestrien(o}, forli=0,i> a) &.ox0f); but appendthesoigitblil & cx: " sbytesToHen(output)}, return but. t2stringt);) ‘output: Message digest object info: Algocitnm = SHA, Provider =SUN version 11 ToStiing = SHAI Massage Digest from SUN, 'SHAA(") = DA33A3EESE6E4BDD32550FEFOSEDIB90AFDE0709 ‘SHAa("sbe"} = AQU93E364706816ABA3E2S71 7ES0C26C9CDODEOD ‘StAa(“abedefghijkimnopqrstuvwnryi"]= 32020C7BECF96S70CAD4CER7FZA1908424003489 ‘Message Digest Algorithms (MDS) AIM: Calculate the message digest of text using the SHA-1 algorithen in JAVA impart java:securty.*; pubic ass DS { public staue void mainisting] a) ( J# TODO code application logic here tev ‘MessageDigest md - MessageDigest.getinstance|"MDS"); system out prnto("Mezsage digest objectinto: System out. panto" Algorithm = * sod gegen) System out pantln(" Provider =" smd getProwiser() System out patie); System out prntn("M5{\"sinputs"\] =" sbytesTeHexfoutput Input = “abe”; d.update(input.getBytes()); output = md digest) ‘System.out panting); ‘System. out printing" MDS{\""+input+"\"} =" sbytesTottexfautput)) Input = “abedefghikimnoparstwrweye"; snd.update(input.gettites()) ‘output = md.sigest); ‘System.out printing); ‘System. out pentin("MDS(\"" sinpute"Y -sbytesToHex(output)):System.out printing"): d ‘atch (Exception e ( System.out printint"Exoeption:* +e); } y public stati Sting bytesToHex(byte[]b) char haxDigi]= (,°X, 2, "4,556, 7,8, "9, ‘A, 8 'C, DY "Fh; Siviggbutf but = new StringBuffer) fora j-0; eb eng: jo) but anpenathesoigtl(l] > a) & 0x00); but. anpencthesoigtbl) & oxo; ) seturn bul tastrngth n ‘output: ‘Message digest object info: Algocithn = MDS Provider =SUN version 11 ToString = MDS Message Digest from SUN, ‘ips (“") = D4108cD9srooaz0se9Ro099BECrEAZ7E ‘ips ‘abc") = 900150383C024FBOD6SE3F7D28E17F72 (MDs ("abedefhijkimnopqrstuvwaye") = C2FCD3076192E 4007DFR496CCAG7ELZE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy