MD5 *** Le MD5 permet d’avoir une empreinte informatique d’une donnée, utile donc pour comparer deux éléments. en python MD5 d’un fichier: .. code-block:: python """ FileHasher.py Alessio Saltarin - 2003 Usage: python FileHasher.py [[file_path]] """ import os import sys import md5 def readfile(filename): f = file(filename,'rb'); print "\nReading %s \n" % f.name; m = md5.new(); readBytes = 1024; # read 1024 bytes per time totalBytes = 0; while (readBytes): readString = f.read(readBytes); m.update(readString); readBytes = len(readString); totalBytes+=readBytes; print "#", f.close(); print print "\nTotal bytes: %d" % totalBytes; print "Md5 : %s"% m.hexdigest(); print if __name__ == '__main__': if (len(sys.argv)==2): readfile(sys.argv[[1]]); else: print "Usage: python FileHasher.py [[file_path]]\n"; on peux aussi avoir un md5 d’une chaine: .. code-block:: python import md5 md5.md5("coucou").hexdigest()