zstd-rs
zstd-rs copied to clipboard
how to use checksum?
Hi,
I am using zstd for very large files and checksum feature is important for my use case. I need more information on how to use this feature:
- When checksum is included from the encoder, how is it calculated?
- For stream of a single file, does this mean there is a single checksum or is there multiple checksums for different parts? where is it stored?
- How do I check if a file is intact?
- does decoder automatically check checksum if there is one?
- The
zstd_safe::CParameter::ChecksumFlag
can be used when compressing to include a single 32-bit checksum (of the original, uncompressed content) per frame (at the end of the frame). In general there is one frame per file, but that's not enforced. It's possible for some files to be a series of zstd frames (by default the decoder just concatenates the decompressed content); each frame would have its own checksum. The checksum uses xxh64 (from xxHash). - When decompressing, checksums are automatically checked if present.
- To "test" a file, you can "decompress" it and throw away the result; it will check that the decompressed content matches the checksum and return an error if it doesn't.