File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Generating a Checksum Value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Generating a Checksum Value" Watch "Generating a Checksum Value" New topic

Generating a Checksum Value

Brendan Crisler

Joined: Feb 07, 2007
Posts: 19
I'm trying to create a 100 byte ASCII string to send over a com port. Byte 99 in the string needs to be an 8-bit checksum. How do I set this byte? I've seen the package, but I'm not sure if that's just used for 'reading' a checksum or not. Any help is appreciated.
Henry Wong

Joined: Sep 28, 2004
Posts: 20525

These days the term checksum doesn't have a meaning, in terms of an actual definition. In the past, it just means the sum of the values of all the bytes in the packet, ignoring overflows. These days, it just means a way to check -- and doesn't really imply that you are taking a sum.

It could be just a sum. It could be a CRC, of which there are tons of formulas. It could be a message digest -- MD5, SHA1, etc. It could be nearly anything. Now, admittedly, many that I listed are not 8-bit, so it may not be those.

Regardless, you need to look up, the actually definition of checksum -- used in your application, as it will be nearly impossible to guess what this thing you are communicating with, is expecting.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: Generating a Checksum Value
It's not a secret anymore!