Created
December 1, 2020 02:34
-
-
Save leandromoreira/a4cd8875e2f24f30c78e38eac36ff4bc to your computer and use it in GitHub Desktop.
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
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