Created
          March 17, 2015 17:07 
        
      - 
      
- 
        Save JamesTheBard/911107e86758f2dd3e08 to your computer and use it in GitHub Desktop. 
    Python md5sum quickie
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from __future__ import print_function | |
| import hashlib | |
| import sys | |
| def md5Checksum(filePath): | |
| with open(filePath, 'rb') as fh: | |
| m = hashlib.md5() | |
| while True: | |
| data = fh.read(8192) | |
| if not data: | |
| break | |
| m.update(data) | |
| return m.hexdigest() | |
| if __name__ == "__main__": | |
| filepath = sys.argv[1] | |
| hash = md5Checksum(filepath) | |
| print("{0}\t{1}".format(hash, filepath)) | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment