加密
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.

20 lines
297 B

3 years ago
  1. package crypter
  2. import (
  3. "crypto/hmac"
  4. "fmt"
  5. "golang.org/x/crypto/ripemd160"
  6. )
  7. func EncryptedToken(token, key string) string {
  8. h2 := hmac.New(ripemd160.New, []byte(key))
  9. h2.Write([]byte(token))
  10. hashBytes := h2.Sum(nil)
  11. hashString := fmt.Sprintf("%x", hashBytes)
  12. return hashString
  13. }