0% found this document useful (0 votes)
7 views1 page

CRC Example

Uploaded by

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

CRC Example

Uploaded by

404sakyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import [Link].

Scanner;
public class CRCExample {
public static string compute CRC(string data,String divisor) {
int n = [Link]();
String remainder = [Link](0,n);
for(int i=n;i<=[Link]();i++) {
if([Link](0) == '1') {
remainder = xor(divisor,remainder);
}else{
remainder = xor("0".repeat(n),remainder);
}
if(i<[Link]()) {
remainder = [Link](1) +[Link](i);
}else{
remainder = [Link](1);
}
}return remainder;
}

publick static string xor(String a, string b) {


string Builder result = new string Builder();
for(int i=0;i<[Link]();i++) {
[Link](([Link](i)==[Link](i)?'0':'1');
}
return [Link]();
}

public static void main(string[] args) {


Scanner sc = new Scanner(System..in);
[Link]("Enter Data(binary):");
string data = [Link]();
[Link]("Enter Divisor(generate polynomial):");
String divisor = [Link]();
String appended Data = data + "0".repeat([Link]()-1);
String crc = compute Crc(appendedDataDivisor);
[Link]("CRC checksum:"+crc);
string transmitted Data = data + crc;
[Link]("Transmitted Data(data+ crc): + transmittedData);
Strting receiverRemainder = computeCRC(transmitted Data,divisor);
if([Link]("1")) {
[Link]("Error Deteted in Received Data/");
}else{
[Link]("NO Error Detected in received Data");
}
[Link]();
}
}

You might also like