| 1234567891011121314151617 |
- package utils
- import (
- "crypto/hmac"
- "crypto/sha1"
- "encoding/hex"
- )
- const (
- hmac_key = "hmac_key_"
- )
- func GenerateToken(plain string) string {
- hash := hmac.New(sha1.New, []byte(hmac_key))
- hash.Write([]byte(plain))
- return hex.EncodeToString(hash.Sum(nil))
- }
|