cypher175 Posted February 6, 2009 Share Posted February 6, 2009 Whats the Best Function/Feature for Comparing 2 Files against each other to see if they are Same/Different..?? Link to comment Share on other sites More sharing options...
Inverted Posted February 6, 2009 Share Posted February 6, 2009 First thing I'd try would be _FileReadToArray for both files. And then comparing the arrays of course. Link to comment Share on other sites More sharing options...
cypher175 Posted February 6, 2009 Author Share Posted February 6, 2009 Nah, i mean like crc32, md5 checksums Ect.. Whats the best fastest way to compare 2 or more files against each other to see if they are same/diff..?? Link to comment Share on other sites More sharing options...
avery Posted February 6, 2009 Share Posted February 6, 2009 Nah, i mean like crc32, md5 checksums Ect..Whats the best fastest way to compare 2 or more files against each other to see if they are same/diff..??md5 I think.I wrote an MD5 checksum tool using MD5Hash.dll from a UDF here on the Forums. It was for Trusted Downloads Process when you take unclass information off a secret pc.. so it's good enough to get approved for that lol.The tool asks for two files using filedialog functions and compares them in a gui I made with KODA. If you want me to share the app PM me please.I hope this helps,averyps:Zzzzzz www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org Link to comment Share on other sites More sharing options...
cypher175 Posted February 6, 2009 Author Share Posted February 6, 2009 isn't there any already premade functions that do theses comparisons to incorporate into our scripts..?? Link to comment Share on other sites More sharing options...
KaFu Posted February 6, 2009 Share Posted February 6, 2009 (edited) SMF utilizes the pure Autoit md5 calculation UDF by Ward:http://www.autoitscript.com:80/forum/index...showtopic=76976You can either use it to calculate the full original md5 hash (can be time consuming) or use the md5(short) mechanism I created especially for SMF (). Depending on file-type you can define chunks of the file to calculate the md5 on, e.g. 5KB or 5MB or any other chunk-size. md5(short) then takes the first chunk, a middle chunk and the last chunk of the file to calculate the md5. Especially on large files this gives a major speed improvement with acceptable accuracy (in my experience). SMF detects duplicates by first comparing the filesize in byte and then calculates md5(short) only for those files with same filesize.The relevant function in SMF is 'md5_calc($filename = "", $type = 1)', type 1 means full, type 2 means short (+some additional checks which you might to have to cut out). The relevant include is SMF_MD5_v03.au3. Edited February 6, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
cypher175 Posted February 6, 2009 Author Share Posted February 6, 2009 so which method is the best/fastest/accurate method to compare 2 files..?? Link to comment Share on other sites More sharing options...
Inverted Posted February 6, 2009 Share Posted February 6, 2009 so which method is the best/fastest/accurate method to compare 2 files..??Check the sizes, and if they are equal, use that cool UDF from that thread to calculate the CRC32 for each. Then compare those 2 results. Should be very easy to do, please don't ask for code, lol. Link to comment Share on other sites More sharing options...
cypher175 Posted February 6, 2009 Author Share Posted February 6, 2009 whats the diff between crc32, md5, sha1 Ect.. which one works best..?? Link to comment Share on other sites More sharing options...
Inverted Posted February 6, 2009 Share Posted February 6, 2009 (edited) They all work fine, I think CRC32 is faster, the others are more "secure" and less susceptible to brute forcing. If you are afraid of faked CRC32, don't use it. If you don't care about speed, use another.But I believe any of these would work fine.And if you have hours to kill ...http://en.wikipedia.org/wiki/Sha1http://en.wikipedia.org/wiki/Crc32http://en.wikipedia.org/wiki/Md5 Edited February 6, 2009 by Inverted Link to comment Share on other sites More sharing options...
cypher175 Posted February 6, 2009 Author Share Posted February 6, 2009 how does brute forcing fit into File comparing using CRC32, MD5, SHA1..?? Link to comment Share on other sites More sharing options...
Inverted Posted February 6, 2009 Share Posted February 6, 2009 how does brute forcing fit into File comparing using CRC32, MD5, SHA1..??If it's security-related, you should know that CRC32 files can be faked in a matter of seconds. Link to comment Share on other sites More sharing options...
cypher175 Posted February 7, 2009 Author Share Posted February 7, 2009 so SHA1 is a better one to go with then.. Im not really using it for security purposes.. its just guna be used to compare files that are going to be moved & copied Ect.. to see if they are same/diff Ect.. and do If/Then Based function base upon if the files are same or diff.. Link to comment Share on other sites More sharing options...
Authenticity Posted February 7, 2009 Share Posted February 7, 2009 There is nothing changed when moving a file relating to it's byte array concept. What might get change is what referring this file so moving a .exe file that rely on some .dll's or some regkey's that rely on file's location might not work if that is the case. Other than that nothing is change in the byte array concept. Link to comment Share on other sites More sharing options...
rogerd2u Posted February 9, 2009 Share Posted February 9, 2009 (edited) Here is a function I use to compare two files -- checks size first, then [last modified] date if the size is identical. It's not nearly as complex as the other script listed, but it seems to get the job done. If the destination location is different, it copies the file from the source location.CompareTwoFiles_CopyIfDifferent.au3 Edited February 9, 2009 by rogerd2u Roger O."When people show you who they are, believe them. --Mark Twain 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