security.go 273 B

1234567891011121314
  1. package objx
  2. import (
  3. "crypto/sha1"
  4. "encoding/hex"
  5. )
  6. // HashWithKey hashes the specified string using the security
  7. // key.
  8. func HashWithKey(data, key string) string {
  9. hash := sha1.New()
  10. hash.Write([]byte(data + ":" + key))
  11. return hex.EncodeToString(hash.Sum(nil))
  12. }