Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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