File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Generating a Checksum Value" Watch "Generating a Checksum Value" New topic
Author

Generating a Checksum Value

Brendan Crisler
Greenhorn

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 java.util.zip package, but I'm not sure if that's just used for 'reading' a checksum or not. Any help is appreciated.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18532
    
  40

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.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generating a Checksum Value
 
Similar Threads
Checksum crc 16 modbus
Calculing the Checksum and adding it to the outputstream
Checksum help (I think)...
HashCode
CheckSum implemantation details for a file