Jump to content
Sign in to follow this  
cypher175

Best Function/Feature for Comparing Files..?

Recommended Posts

cypher175

Whats the Best Function/Feature for Comparing 2 Files against each other to see if they are Same/Different..??

Share this post


Link to post
Share on other sites
Inverted

First thing I'd try would be _FileReadToArray for both files. And then comparing the arrays of course.

Share this post


Link to post
Share on other sites
cypher175

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..??

Share this post


Link to post
Share on other sites
avery

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,

avery

ps:Zzzzzz


www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org

Share this post


Link to post
Share on other sites
cypher175

isn't there any already premade functions that do theses comparisons to incorporate into our scripts..??

Share this post


Link to post
Share on other sites
KaFu

SMF utilizes the pure Autoit md5 calculation UDF by Ward:

http://www.autoitscript.com:80/forum/index...showtopic=76976

You 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 by KaFu

Share this post


Link to post
Share on other sites
cypher175

so which method is the best/fastest/accurate method to compare 2 files..??

Share this post


Link to post
Share on other sites
Inverted

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.

Share this post


Link to post
Share on other sites
cypher175

whats the diff between crc32, md5, sha1 Ect.. which one works best..??

Share this post


Link to post
Share on other sites
Inverted

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/Sha1

http://en.wikipedia.org/wiki/Crc32

http://en.wikipedia.org/wiki/Md5

Edited by Inverted

Share this post


Link to post
Share on other sites
cypher175

how does brute forcing fit into File comparing using CRC32, MD5, SHA1..??

Share this post


Link to post
Share on other sites
Inverted

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.

Share this post


Link to post
Share on other sites
cypher175

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..

Share this post


Link to post
Share on other sites
Authenticity

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.

Share this post


Link to post
Share on other sites
rogerd2u

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 by rogerd2u

Roger O."When people show you who they are, believe them.” --Mark Twain

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×