Skip to content

Instantly share code, notes, and snippets.

@vuduongtp
Created October 26, 2022 01:28
Show Gist options
  • Save vuduongtp/8ea068fbc60bb8173b49d7972e34fd3a to your computer and use it in GitHub Desktop.
Save vuduongtp/8ea068fbc60bb8173b49d7972e34fd3a to your computer and use it in GitHub Desktop.
Golang - Hash message by SHA256
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