|
@@ -20,6 +20,7 @@ func SHA512(data []byte) ([]byte, error) {
|
|
|
return hash.Sum(nil), nil
|
|
|
}
|
|
|
|
|
|
+// HmacSHA256 hmac with sha256
|
|
|
func HmacSHA256(k, s []byte) ([]byte, error) {
|
|
|
hash := hmac.New(sha256.New, k)
|
|
|
_, err := hash.Write(s)
|
|
@@ -49,3 +50,13 @@ func SHA1(data string) string {
|
|
|
hash.Write([]byte(data))
|
|
|
return hex.EncodeToString(hash.Sum(nil))
|
|
|
}
|
|
|
+
|
|
|
+// HmacSHA1 hmac with sha1
|
|
|
+func HmacSHA1(k, s []byte) ([]byte, error) {
|
|
|
+ hash := hmac.New(sha1.New, k)
|
|
|
+ _, err := hash.Write(s)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return hash.Sum(nil), nil
|
|
|
+}
|