Created
November 2, 2014 23:28
-
-
Save jayswan/e821ed60914644e2e811 to your computer and use it in GitHub Desktop.
This file contains 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 | |
def hash(s,a='md5'): | |
""" One-stop hex-digest of a string. Allows any algorithm supported by hashlib. """ | |
f = getattr(hashlib,a) | |
return f(s).hexdigest() | |
def fhash(fn,a='md5'): | |
""" Hash a file as a string. Not memory considerate. """ | |
with open(fn) as f: | |
contents = f.read() | |
return hash(contents,a) | |
def main(): | |
pass | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment