github.com/fzfile/BaiduPCS-Go@v0.0.0-20200606205115-4408961cf336/baidupcs/netdisksign/devuid.go (about) 1 package netdisksign 2 3 import ( 4 "bytes" 5 "crypto/md5" 6 "encoding/hex" 7 "github.com/fzfile/BaiduPCS-Go/pcsutil/cachepool" 8 "github.com/fzfile/BaiduPCS-Go/pcsutil/converter" 9 ) 10 11 func DevUID(feature string) string { 12 m := md5.New() 13 m.Write(converter.ToBytes(feature)) 14 res := m.Sum(nil) 15 resHex := cachepool.RawMallocByteSlice(34) 16 hex.Encode(resHex[2:], res) 17 resHex[0] = 'O' 18 resHex[1] = '|' 19 return converter.ToString(bytes.ToUpper(resHex)) 20 }