Skip to content

Instantly share code, notes, and snippets.

@alfg
Created April 20, 2012 22:36
Show Gist options
  • Save alfg/2432357 to your computer and use it in GitHub Desktop.
Save alfg/2432357 to your computer and use it in GitHub Desktop.
Simple script to get both MD5 and SHA1 hash of any file.
#!/usr/bin/env python
# Simple script to get both MD5 and SHA1 hash of any file.
import sys
import hashlib
if len(sys.argv) < 2:
sys.exit('Usage: %s filename' % sys.argv[0])
stream = sys.argv[1]
file = open(stream, "rb").read()
md5 = "MD5: " + hashlib.md5(file).hexdigest()
sha1 = "SHA1: " + hashlib.sha1(file).hexdigest()
print md5
print sha1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment