parent
30c963a5f0
commit
61a1c93f0f
89 changed files with 15859 additions and 2 deletions
17
server/libs/encrypt/encrypter_hmac.go
Normal file
17
server/libs/encrypt/encrypter_hmac.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
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))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue