main.go195 chars12 lines
First, we import the crypto/sha3
package for the SHA3_256 hashing function and the encoding/hex
package for hex encoding.
We then create a function which takes a string as input, hashes it using SHA3_256 algorithm and encodes the hash output using hex encoding.
The input string is first converted to a byte slice using []byte(str)
and then passed as an argument to the sha3.Sum256()
function which computes the hash.
The resulting hash is returned as a fixed-size array of bytes, which we convert to a string using hex.EncodeToString(hash[:])
.
Finally, we print the hash string to the console.
gistlibby LogSnag