I want to store hashes as binary (64 bytes). But for any type of API (web service) I would want to pass them around as strings. hashlib.hexdigest() will give me a string, and hashlib.digest() will give me the binary. But if, for example, I read in the binary version from disk, how would I convert it to a string? And if I read in the string from a web service, how would I convert it to binary?
I want to store hashes as binary (64 bytes). But for any type of
Share
You could start with the string version to pass around and display:
Convert it to binary to write it to disk:
When reading it back from disk, convert it back to a string: