6/10/2023 0 Comments Checksum calculator ubuntu![]() On Ubuntu, at least, /usr/bin/crc32 is a short Perl script, and you can see quite clearly from its source that all it can do is open files. I'd suggest if you're using this you should try some test values and compare with the results of an online tool.ĮDIT As suggested by in the comments, you can pipe the output into od instead of hexdump for identical results without the fiddly options. The weak point here for cross-platform usability is probably the hexdump configuration, since I have seen variations on it from platform to platform and it's a bit fiddly. Like I say, not the most elegant solution, and perhaps not an approach you'd want to use in a performance-sensitive scenario but an approach that might appeal given the near universality of the commands used. If you want a hexadecimal checksum you can change the format string to '"%08x"' (or '"%08X"' for upper case hex) which will format the checksum as 8 character (0 padded) hexadecimal. Notice that there are double quotes nested within single quotes here. '"%u"' is your standard fprintf format string that formats the bytes as a single unsigned 32-bit integer.-n4 takes only the relevant first 4 bytes of the gzip footer.Hexdump was a little trickier and I had to futz about with it for a while before I came up with something satisfactory, but the format here seems to correctly parse the gzip crc32 as a single 32-bit number: ( -1 as suggested by so we don't waste time actually doing the compression). ![]() Just to provide some technical details, gzip uses crc32 in the last 8 bytes and the -c option causes it to output to standard output and tail strips out the last 8 bytes. echo -n "LongString" | gzip -1 -c | tail -c8 | hexdump -n4 -e '"%u"' I came up with this, and although it's a little nasty it should work on most platforms, or most modern linux anyway. I came up against this problem myself and I didn't want to go to the "hassle" of installing crc32.
0 Comments
Leave a Reply. |