utils.go 425 B

1234567891011121314151617181920
  1. package main
  2. import (
  3. "crypto/md5"
  4. "encoding/hex"
  5. "fmt"
  6. "strconv"
  7. )
  8. func genDeviceIdentifier(vendor int32, product uint, device string) string {
  9. return strconv.FormatInt(int64(vendor), 16) + "-" + strconv.FormatInt(int64(product), 16) + "-" + device
  10. }
  11. // mdd md5加密
  12. func mdd(s string) string {
  13. h := md5.New()
  14. h.Write([]byte(s))
  15. cipherStr := h.Sum(nil)
  16. return fmt.Sprintf("%s", hex.EncodeToString(cipherStr))
  17. }