forked from BRUHItsABunny/crypto-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhmac.go
More file actions
32 lines (28 loc) · 694 Bytes
/
Copy pathhmac.go
File metadata and controls
32 lines (28 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package crypto_utils
import (
"crypto/hmac"
"crypto/sha1"
"crypto/sha256"
"github.com/OneOfOne/xxhash"
)
func HMACofSHA1(key []byte, args ...[]byte) []byte {
digester := hmac.New(sha1.New, key)
for _, msgBytes := range args {
digester.Write(msgBytes)
}
return digester.Sum(nil)
}
func HMACofSHA256(key []byte, args ...[]byte) []byte {
digester := hmac.New(sha256.New, key)
for _, msgBytes := range args {
digester.Write(msgBytes)
}
return digester.Sum(nil)
}
func HMACofXXHash(key []byte, args ...[]byte) []byte {
digester := hmac.New(xxhash.NewHash32, key) //Using 64bit or 32bit?
for _, msgBytes := range args {
digester.Write(msgBytes)
}
return digester.Sum(nil)
}