CryptoUtil.go 410 B

1234567891011121314151617181920212223
  1. package Utils
  2. import (
  3. "crypto/md5"
  4. "encoding/hex"
  5. "fmt"
  6. "io"
  7. )
  8. //生成32位md5字串
  9. func GetMd5(input string) string {
  10. hash := md5.New()
  11. hash.Write([]byte(input))
  12. return hex.EncodeToString(hash.Sum(nil))
  13. }
  14. func GetSaltMD5(input, salt string) string {
  15. hash := md5.New()
  16. //salt = "salt123456" //盐值
  17. io.WriteString(hash, input+salt)
  18. result := fmt.Sprintf("%x", hash.Sum(nil))
  19. return result
  20. }
粤ICP备19079148号