論壇系統(tǒng)太2了,代碼都顯示不全.
func main() {
mac := "04:95:73:BE:48:5A"
rand := "C59396"
if rand[0] == 'C' {
rand_len := len(rand)
mac_b := []byte(mac)
mac_len := len(mac_b)
mac_b[mac_len-1] = rand[rand_len-1]
offset := 0
for i, v := range mac_b {
if v == byte(':') {
mac_b[i] = byte(rand[offset])
offset += 1
}
}
mac = string(mac_b)
}
fmt.Println(getCode(mac, rand))
}
func getCode(mac, rand string) int32 {
str := fmt.Sprintf("%s%s%s%s%s", "open_ADB", rand, "@", mac, "ZTE_ENCRYPT")
fmt.Printf("str: %s\n", str)
h := md5.New()
h.Write([]byte(str))
checkSum := strings.ToUpper(hex.EncodeToString(h.Sum(nil)))
fmt.Printf("checkSum: %s\n", checkSum)
clen := len(checkSum)
var result int32 = 0
for i := 0; i < clen; i++ {
result = int32(checkSum[i]) + 31*result
}
if result < 0 {
result = -result
}
return result
} |