You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
348 B
Go
18 lines
348 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gogf/gf/crypto/gmd5"
|
|
"github.com/gogf/gf/util/guid"
|
|
)
|
|
|
|
func GenerateToken(uid interface{}) (string, error) {
|
|
// 生成一个随机的 GUID 作为 token
|
|
token := guid.S()
|
|
// 使用 MD5 加密 token
|
|
encryptedToken, err := gmd5.Encrypt(token)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return encryptedToken, nil
|
|
}
|