This commit is contained in:
2020-02-10 00:10:47 +08:00
parent f335497984
commit 671bd277ad

19
single_file_tests/hmac.go Normal file
View File

@@ -0,0 +1,19 @@
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))
}