Files
golang-tests/single_file_tests/hmac.go
2020-02-10 00:10:47 +08:00

20 lines
310 B
Go

package main
import (
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"fmt"
)
func main() {
key := []byte("aaaaaa")
mac := hmac.New(sha1.New, key)
mac.Write([]byte("Hello World!"))
hmacSum := mac.Sum(nil)
fmt.Printf("%x\n", hmacSum)
fmt.Printf("%s\n", base64.StdEncoding.EncodeToString(hmacSum))
}