quickshare/server/libs/encrypt/encrypter_hmac.go
hekk 61a1c93f0f !1 Merge back to master
Merge pull request !1 from dev branch
2018-05-27 21:32:55 +08:00

17 lines
292 B
Go

package encrypt
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
)
type HmacEncryptor struct {
Key []byte
}
func (encryptor *HmacEncryptor) Encrypt(content []byte) string {
mac := hmac.New(sha256.New, encryptor.Key)
mac.Write(content)
return hex.EncodeToString(mac.Sum(nil))
}