The fastest way is just to compare hash code of files having same size. <br> This is the idea of of this [answer on SO](http://stackoverflow.com/a/9145286) (see the second command line and its explanations). There is no security issue while detecting duplicated files, therefore I would recommand a fast hashing code. For instance the project [ccache](http://ccache.samba.org/manual.html#_how_ccache_works) uses MD4: > ccache uses MD4, a very fast cryptographic hash algorithm, for the hashing. > (MD4 is nowadays too weak to be useful in cryptographic contexts, > but it should be safe enough to be used to identify recompilations.)