Skip to content

Instantly share code, notes, and snippets.

@doberkofler
Created February 16, 2013 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doberkofler/4968756 to your computer and use it in GitHub Desktop.
Save doberkofler/4968756 to your computer and use it in GitHub Desktop.
Retrieve the SHA1 for a file
import hashlib
import re
def getOraclePackageSHA1(fileName):
content = open(fileName).read()
pattern = "(PACKAGE.*;)\s*/"
compiled = re.compile(pattern, re.IGNORECASE | re.DOTALL | re.MULTILINE)
match = compiled.search(content)
if match:
content = match.group(1)
sha1 = hashlib.sha1()
sha1.update(content)
return sha1.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment