diff options
Diffstat (limited to 'combox/file.py')
-rw-r--r-- | combox/file.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/combox/file.py b/combox/file.py index 563e8cd..e4677e9 100644 --- a/combox/file.py +++ b/combox/file.py @@ -18,6 +18,7 @@ import os +from hashlib import sha512 from os import path from sys import exit from glob import glob @@ -243,6 +244,18 @@ def read_file(filename): return file_.read() +def hash_file(filename): + """Does a SHA512 hash on the contents of file. + + Returns the hexdigest of the file content's hash. + + filename: Absolute pathname of the file. + """ + file_content = read_file(filename) + + return sha512(file_content).hexdigest() + + def write_file(filename, filecontent): """Write `filecontent' to `filename'. |