gawk / awk implimentation crc32 (compatible with the POSIX cksum command)
Here is an example of using awk (gawk) crc32. Please note that we use T and X as our lookup table. T used for crc32_table, and X used to search for data in an int value.
If you want, you can calculate crc32_table at runtime, however it was a little slow at startup, so you will have a compromise between small codesize and slow tartup or Reasonable speed crc32 calculation and large code size . I would recommend a version with crc_table, as increasing the size of the code was justified when comparing speed.
If you have an awk version that does not support and(),xor(),compl(),lshift(),rshift() , be sure to download the bitwise operational files.
BEGIN{
Then calculate crc32
# Limit var size to 32bit function u32(v){return and(v,0xffffffff)} {
Result
crc=[4294967295] <-- "" crc=[1220704766] <-- "a" crc=[1219131554] <-- "abc" crc=[3644109718] <-- "message digest"
All crc32 values ββare the same as the cksum command cksum
source share