add hmac
This commit is contained in:
19
single_file_tests/hmac.go
Normal file
19
single_file_tests/hmac.go
Normal 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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user