Created
February 10, 2019 04:05
-
-
Save edwinlab/335011e1e20ac72445d687539d4f004c to your computer and use it in GitHub Desktop.
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 ( | |
"crypto/hmac" | |
"crypto/sha256" | |
"encoding/base64" | |
"encoding/hex" | |
) | |
func main() { | |
secret := []byte("the shared secret key here") | |
message := []byte("the message to hash here") | |
hash := hmac.New(sha256.New, secret) | |
hash.Write(message) | |
// to lowercase hexits | |
hex.EncodeToString(hash.Sum(nil)) | |
// to base64 | |
base64.StdEncoding.EncodeToString(hash.Sum(nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment