So im writing a smiple File Integrity Monitor. And im trying to hash the contents of a file and store it as a baseline. This is my code:
from base64 import encode
import hashlib
h =hashlib.sha512()
with open ("baseline.txt", 'r') as f:
contents = f.read()
h.update(contents.encode('utf8'))
hash = h.hexdigest
print(hash)
And this is my output:
<built-in method hexdigest of _hashlib.HASH object at 0x000001E3096B5250>
Im not sure what is causing the output to come out this way. I suspect that it has to do with how im opening the file and the format it is coming out in. If you could help me with this or point me in the right direction woudld be great.
hexdigest
is a function:)
Try hash = h.hexdigest()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.