Last active
September 14, 2024 17:54
-
-
Save devlongs/b0db3e4e4f94cbf92374b02b6fcb2739 to your computer and use it in GitHub Desktop.
Keccahk256 hashing in Go using the golang.org/x/crypto/sha3 library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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