Created
February 16, 2013 21:10
-
-
Save doberkofler/4968756 to your computer and use it in GitHub Desktop.
Retrieve the SHA1 for a file
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
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