site
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
397 B

package site
import (
"crypto/hmac"
"fmt"
"golang.org/x/crypto/ripemd160"
)
func EncryptedUserToken(token string, key ...string) string {
var token_key string = USER_TOKEN_KEY
if len(key) > 0 {
token_key = key[0]
}
h2 := hmac.New(ripemd160.New, []byte(token_key))
h2.Write([]byte(token))
hashBytes := h2.Sum(nil)
hashString := fmt.Sprintf("%x", hashBytes)
return hashString
}