20 lines
310 B
Go
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))
|
|
}
|
|
|