ソースを参照

update hmac sha1

ls 1 年間 前
コミット
fa526bda21
1 ファイル変更11 行追加0 行削除
  1. 11 0
      hash.go

+ 11 - 0
hash.go

@@ -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
+}