Mbee Posted January 22, 2018 Share Posted January 22, 2018 (edited) I have scripts that use _Crypt_HashFile() to generate a hash of an entire file, binary or otherwise. But some of these scripts are hashing huge video files, which take a fairly long time, so I'm looking at finding faster alternatives. One obvious alternative would be to only hash a portion of the file in question, and only calculate the hash value of the entire file when collisions occur. _Crypt_HashData() seems to offer a way to do this. I would read in some portion of the file and then call it and save the hash of the partial file in the hash table. Unfortunately, the function does not include a length or size parameter; all the examples of using that function only pass a text string, for which AutoIt always knows the length. But what if I try to use it on binary data? For example, I could have my script initially hash only the first, say, 20 KB of the file. But what happens when the file is only 10 KB long? How would I tell the _Crypt_HashData() function how many bytes to hash? I'm asking here instead of playing with trial and error, since using hashing functions is not trivial. Can anyone help, please? Thanks! ETA: When I look at the relevant article on MSDN, the call does include a length parameter. Edited January 22, 2018 by Mbee ETA Windows function info Link to comment Share on other sites More sharing options...
RTFC Posted January 22, 2018 Share Posted January 22, 2018 A faster alternative is this: Mbee 1 My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Mbee Posted January 22, 2018 Author Share Posted January 22, 2018 1 minute ago, RTFC said: A faster alternative is this: Okay, I wasn't familiar with that UDF, so please accept my tremendous thanks! But it'll take me a while to see if I'm smart enough to modify trancexx's code to enable hashing of partial files... Link to comment Share on other sites More sharing options...
RTFC Posted January 22, 2018 Share Posted January 22, 2018 (edited) See posts #7 and #14 in that thread for exactly that. Edited January 22, 2018 by RTFC My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Mbee Posted January 22, 2018 Author Share Posted January 22, 2018 6 minutes ago, RTFC said: See posts #7 and #14 in that thread for exactly that. Wow, are you amazingly helpful! Thanks! A question, though: In Post 14, he-she (trancexx doesn't like anyone prejudging gender by using specific pronouns) provides the code for a function named _MD5ForFirstFileChunk(). Where the hell does that come from? From Ward? Should I just use the code on that page, or is there some other UDF I should be using in addition to trancexx's UDF? Link to comment Share on other sites More sharing options...
Mbee Posted January 23, 2018 Author Share Posted January 23, 2018 Okay, I'm going to simply use the code trancexx posted in #14 (with attribution, of course -- I always strive to do that).... Link to comment Share on other sites More sharing options...
RTFC Posted January 23, 2018 Share Posted January 23, 2018 UDF MD5ForFirstFileChunk is in post #41 of that thread. My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Mbee Posted January 24, 2018 Author Share Posted January 24, 2018 15 hours ago, RTFC said: UDF MD5ForFirstFileChunk is in post #41 of that thread. Thank you most kindly once again! I truly appreciate your assistance! I genuinely hope I haven't annoyed you, what with my failing to RTFT... Link to comment Share on other sites More sharing options...
RTFC Posted January 24, 2018 Share Posted January 24, 2018 No worries. You're welcome. My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now