package hash import ( "crypto/hmac" "crypto/md5" "crypto/sha1" "crypto/sha256" "crypto/sha512" ) // HmacMD5 hmac md5 hash func HmacMD5(k, bs []byte) (hs []byte, err error) { h := hmac.New(md5.New, k) _, err = h.Write(bs) if err != nil { return } hs = h.Sum(nil) return } // HmacSHA1 hmac sha1 hash func HmacSHA1(k, bs []byte) (hs []byte, err error) { h := hmac.New(sha1.New, k) _, err = h.Write(bs) if err != nil { return } hs = h.Sum(nil) return } // HmacSHA256 hmac sha256 hash func HmacSHA256(k, bs []byte) (hs []byte, err error) { h := hmac.New(sha256.New, k) _, err = h.Write(bs) if err != nil { return } hs = h.Sum(nil) return } // HmacSHA512 hmac sha256 hash func HmacSHA512(k, bs []byte) (hs []byte, err error) { h := hmac.New(sha512.New, k) _, err = h.Write(bs) if err != nil { return } hs = h.Sum(nil) return }