To create a BLAKE2s hash from a string in PHP, you can use the hash()
function with the "blake2s" algorithm:
main.php73 chars4 lines
This will output the BLAKE2s hash of the string "Hello, world!" in hexadecimal format.
You can also specify a custom hash length and a custom key for the BLAKE2s hash:
main.php264 chars10 lines
This will output the BLAKE2s hash of the string "Hello, world!" with a length of 32 bytes and a custom key "my-secret-key". The hash will be output in hexadecimal format. Note that we use the bin2hex()
function to convert the raw binary hash to hexadecimal format.
gistlibby LogSnag