To create a blake2b hash from a string in python, you can use the blake2b
module from the cryptography
library.
Here's an example code snippet:
main.py267 chars10 lines
In this code, we first create a hashes.Hash
object, specifying the hashes.BLAKE2b
algorithm with a 64-byte output size. We then update the hash object with our message string (encoded as UTF-8), and finalize it to get the hash value. Finally, we print out the hash value as a hex string.
Note that for security purposes, it's generally recommended to use a secure salt and key to hash your message string.
gistlibby LogSnag