Is there a way to calculate a checksum on a string in Linux? The checksum commands that I have seen (cksum
, md5sum
, sha1sum
, etc.) all require a file as input and I do not have a file. I only have a path to a location and want to calculate the checksum on that path.
The checksum should be alphanumeric. The strings are unicode. The strings are actually texts that should be translated and the checksum is stored with each translation (so a translated text can be matched back to the original text). The length of the checksum is not important for me (the shorter, the better)
Checksum From a String or Byte Array The first thing we need to do is to obtain the input to the checksum algorithm. Here, we are using Java's built-in CRC32 class. Once the class is instantiated, we use the update method to update the Checksum instance with the bytes from the input.
To calculate the checksum of an API frame: Add all bytes of the packet, except the start delimiter 0x7E and the length (the second and third bytes). Keep only the lowest 8 bits from the result. Subtract this quantity from 0xFF.
echo -n 'exampleString' | md5sum
should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With