Created
October 26, 2022 01:28
-
-
Save vuduongtp/8ea068fbc60bb8173b49d7972e34fd3a to your computer and use it in GitHub Desktop.
Golang - Hash message by SHA256
This file contains 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
import ( | |
"crypto/sha256" | |
"fmt" | |
) | |
// SHA256 hash message by SHA256 | |
func SHA256(plaintext string) *string { | |
data := []byte(plaintext) | |
hash := sha256.Sum256(data) | |
hashString := fmt.Sprintf("%x", hash[:]) | |
return &hashString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment