header checksum

142 views
Skip to first unread message

compdecomp7

unread,
Aug 22, 2017, 2:53:10 PM8/22/17
to LZ4c

I have a compressed block that was compressed as per the lz4 algorithm. But it doesn't have the Frame/Header at the beginning or the footer that contains the content checksum at the end. I have the original file that was compressed.

 

I would like to use the "./lz4 -d" command to check the correctness of the compression. My questions are

 

  1. Does the lz4 command have any option so that I can use the "./lz4 -d " command to decompress a file that doesn't have the Frame/footer at the beginning or the content checksum at the end?
  2. My plan is to create the Frame/header with the content checksum (C.Checksum) disabled as per the Frame descriptor but I am not very familiar with the xxhash so I don't know how to create the HC/header checksum for that Frame descriptor. Is there any command line utility that I can use to find the header checksum if I provide the frame in a file? I am looking for some thing like    @xxhash header_in_a_file >header_checksum

Thanks in advance
   

Cyan

unread,
Aug 22, 2017, 3:15:00 PM8/22/17
to LZ4c
> 1. Does the lz4 command have any option so that I can use the "./lz4 -d " command to decompress a file that doesn't have the Frame/footer at the beginning

Nope. Frame header is compulsory for the lz4 command.


> 2. Is there any command line utility that I can use to find the header checksum if I provide the frame in a file? 

Yes. The xxhsum utility, provided as part of xxhash repository, can give this information.
Select the 32-bits variant for lz4.

compdecomp7

unread,
Aug 22, 2017, 5:59:08 PM8/22/17
to LZ4c

Thanks a lot Yann, for pointing to the xxhsum.

 

 But I have some other confusion now. Following is the xxd of a compressed file that I compressed using ./lz4 command.

 

0000000: 0422 4D18 6440 A747  ."M.d@.G

0000008: 0000 8030 3031 3132  ...00112

0000010: 3233 3334 3435 3536  23344556

0000018: 3637 3738 3861 6162  67788aab

0000020: 6263 6364 6465 6566  bccddeef

0000028: 6667 6768 6869 696A  fgghhiij

0000030: 6A6B 6B6C 6C6D 6D6E  jkkllmmn

0000038: 6E6F 6F70 7071 7172  nooppqqr

0000040: 7273 7374 7475 7576  rssttuuv

0000048: 7677 7778 7879 797A  vwwxxyyz

0000050: 7A0A 0000 0000 1864  z......d

0000058: AB40                 .@

 

I believe A7 is the header checksum for this file.

 

To see if I am using the xxhsum correctly , I grabbed the first 6 bytes of the compressed .lz4 file and dumped it into a file

 . So I now have the frame descriptor only without the header checksum.  Now when I run the xxhsum on this 6 byte file this is what I see

 

%xxhsum -H0 myfile.1.lz4.frame.no_HC

7c920c9b  myfile.1.lz4.frame.no_HC

 

The second byte should be a7 but it is 0c . Am I doing something wrong?

 

Regards.

compdecomp7

unread,
Aug 22, 2017, 6:12:47 PM8/22/17
to LZ4c
Here's the xxd of the 6 byte header file without the HC

0000000: 0422 4D18 6440       ."M.d@

Cyan

unread,
Aug 22, 2017, 7:28:40 PM8/22/17
to LZ4c
The header checksum is the "one-byte checksum of combined descriptor fields"
descriptor fields do not include the initial magic number.

In your example, the checksum should be calculated on the last two bytes only.

compdecomp7

unread,
Aug 22, 2017, 8:01:59 PM8/22/17
to LZ4c
Thanks again, Yann. I see the expected results now for both the header and the content checksum.
Reply all
Reply to author
Forward
0 new messages