A string is known, and the 16 sum of the string is given, and a string and a checksum code are known, and the checksum additive is valid, but not much. directly on the code
public static string Makechecksum (String data) {
if (data = null | | data.equals ("")) {return
"";
}
int total = 0;
int len = Data.length ();
int num = 0;
while (Num < len) {
String s = data.substring (num, num + 2);
System.out.println (s);
Total + = Integer.parseint (s,);
num = num + 2;
}
/**
* With 256 of the maximum is 255, that is, 16-in
FF
/int mod = total% 256;
String hex = integer.tohexstring (mod);
Len = Hex.length ();
If the length of the check bit is not enough, fill 0, here is the two-digit checksum
if (Len < 2) {
hex = "0" + hex;
}
return hex;
}
The above Java cumulative and verify implementation of the way 16 (recommended) is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.