Skip to content

Instantly share code, notes, and snippets.

@devlongs
Last active September 14, 2024 17:54
Show Gist options
  • Save devlongs/b0db3e4e4f94cbf92374b02b6fcb2739 to your computer and use it in GitHub Desktop.
Save devlongs/b0db3e4e4f94cbf92374b02b6fcb2739 to your computer and use it in GitHub Desktop.
Keccahk256 hashing in Go using the golang.org/x/crypto/sha3 library
package main
import (
"fmt"
"golang.org/x/crypto/sha3"
)
func main() {
data := "Hello, Ethereum!"
// Create a new Keccak-256 hash object
hash := sha3.NewLegacyKeccak256()
// Write data to the hash object
hash.Write([]byte(data))
// Get the final hash sum
hashSum := hash.Sum(nil)
// Print the hash as a hexadecimal string
fmt.Printf("Keccak256 Hash: %x\n", hashSum)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment