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 }