I saved this piece of code as hash.py
and when I produce the hash of this file it gives me a hash totally differing from the inbuilt (using KUbuntu 13.04), Now why is that so ? Aren't they both supposed to produce the same result. I also have to mention that for calculating hash value of huge files (I tested on 4.5GB iso file) with the inbuilt md5sum it at least takes 7 seconds but this python file is almost instant
""" filename: hash.py """
import sys
import hashlib
file_name = sys.argv[0]
hash_obj = hashlib.md5(file_name)
print "MD5 - "+ hash_obj.hexdigest()
Output:
meow@VikkyHacks:~/Arena/py$ python hash.py
MD5 - d18a4085140ad0c8ee7671d8ba2065fc
Output from the inbuilt default command:
meow@VikkyHacks:~/Arena/py$ md5sum hash.py
5299f3588cb0de6cf27930181be73e80 hash.py