Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
Created December 1, 2020 02:34
Show Gist options
  • Save leandromoreira/a4cd8875e2f24f30c78e38eac36ff4bc to your computer and use it in GitHub Desktop.
Save leandromoreira/a4cd8875e2f24f30c78e38eac36ff4bc to your computer and use it in GitHub Desktop.
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
)
func main() {
handle := "@someone"
secret := "secret" // belonging to handle
tweet := "tweeted a cat"
h := hmac.New(sha256.New, []byte(secret))
h.Write([]byte(tweet))
sign := hex.EncodeToString(h.Sum(nil))
sep := "---------------------------------------"
fmt.Printf("%s\n%s \n%s \n{sign=%s}\n%s\n", sep, handle, tweet, sign[0:10], sep)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment