Hello all, I have read FLAC stores a hashsum inside its files to check their integrity. But how to do it without having to extract the file? Is the hashsum calcu- lated on the extracted or compressed data? Thanks in advance, Anton
Anton Shepelev wrote:> I have read FLAC stores a hashsum inside its files > to check their integrity. But how to do it without > having to extract the file? Is the hashsum calcu- > lated on the extracted or compressed data?I'm not sure what you're asking for, but the hash is computed on the raw sample data. Raw samples are compressed inside the FLAC file. To extract the computed hash (MD5): metaflac --show-md5sum audio.flac To extract the raw sample data and do the MD5 hash computation another way you can uncompress the FLAC file, convert it to raw with a program like sox(1), and recompute the MD5 hash: flac --decode audio.flac (this creates audio.wav) sox audio.wav audio.raw (this creates audio.raw) md5sum audio.raw (this should match the hash above) For example: $ metaflac --show-md5sum audio.flac 7853aca9317d3b348b3aad5219fa63c9 $ flac --decode --silent audio.flac $ sox audio.wav audio.raw $ md5sum audio.raw 7853aca9317d3b348b3aad5219fa63c9 audio.raw I hope this helps.
Anton Shepelev wrote:> I have read FLAC stores a hashsum inside its files > to check their integrity. But how to do it without > having to extract the file? Is the hashsum calcu- > lated on the extracted or compressed data?I should have mentioned before that apparently the MD5 hash is computed on the uncompressed raw sample data and the easiest way to check the FLAC file is with flac --verify audio.flac --verify won't extract the data to a file, but it does seem to run over the entire file (as one would expect of such a function).
J.B. Nicholson-Owens:> I'm not sure what you're asking forI have a huge archive of FLAC files and want auto- matically to check the integrity thereof, so as if some file be reported as corrupted I can restore it from a mirror backup.> I should have mentioned before that apparently the > MD5 hash is computed on the uncompressed raw sam- > ple data and the easiest way to check the FLAC > file is with > > flac --verify audio.flac >This doesn't work, and the official FLAC focumenta- tion says this option is only applicable to WAV files: -V, --verify Verify the encoding process. With this option, flac will create a parallel decoder that decodes the output of the encoder and compares the result against the original. It will abort immediately with an error if a mismatch occurs. -V increases the total encoding time but is guaranteed to catch any unforseen bug in the encoding process. It seems to have nothing to do with the MD5 hash. The procedure you have described in your previous reply is quite complicated for an automatic check- ing. Why does FLAC calculate MD5 on the RAW uncom- pressed data? If it were using compressed data instead the checking wouldn't require decompression and would be quicker: just calculate the hash on the binary file and compare it against the stored value... Anton
Reasonably Related Threads
- Checking file integrity
- Slowdown on lots of motion
- [PATCH RFC v5 4/8] pvqspinlock, x86: Allow unfair spinlock in a real PV environment
- [PATCH RFC v5 4/8] pvqspinlock, x86: Allow unfair spinlock in a real PV environment
- puppetdb = rise in exection expired notices?