To create a SHA3-512 hash from a string in Go, you can use the sha3
package from the golang.org/x/crypto
module as follows:
main.go179 chars13 lines
In the above example, we first import the fmt
and sha3
packages. We then define a string variable called input
which we want to hash. We then call the sha3.Sum512()
function passing in the input string converted to byte array. This function returns a fixed-size SHA3-512 hash which we can then print using the %x
format specifier in fmt.Printf()
function.
Note that because SHA3 hashes are considered cryptographically secure, you should use them for sensitive data such as passwords, credit card numbers, etc.
gistlibby LogSnag