forked from alexanderritola/Go-Unlock-Code-Calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZTE.go
107 lines (102 loc) · 1.95 KB
/
ZTE.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package main
import (
"strings"
"strconv"
"fmt"
"crypto/md5"
"io"
)
//ZTE SFR 114
//ZTE SFR 231
//ZTE SFR 232
//ZTE SFR 241
//ZTE SFR 251
//ZTE SFR 251MSN
//ZTE SFR 341
//ZTE SFR 342
//ZTE SFR 343
//ZTE ORANGE Vegas
//ZTE ORANGE MIAMI
//ZTE VODAFONE INDIE
//ZTE X760
//ZTE X761
//ZTE X960
//ZTE GX760
//ZTE GX761
//ZTE A261+
//ZTE GR230
//ZTE X990
//ZTE T-Mobile Vairy Touch
//ZTE N261 = N281
//ZTE X990
//ZTE X991
//Orange Rio
func zteOld(imei string) []string{ //zteB02?
var (
magic = [12]int{6, 8, 8, 9, 5, 0, 0, 0, 0, 0, 0, 0}
digits []int
nck = ""
spck = ""
crosssum = 0
)
for i,_ := range imei[3:15]{
imeiAsInt, err := strconv.Atoi(string(imei[i+3]))
if err != nil{
panic(err)
}
digits = append(digits, imeiAsInt)
}
for i,_ := range digits{
crosssum += digits[i]
}
for i,_ := range(digits){
code := (digits[i]*crosssum + digits[11-i]*8 + magic[i]) % 10
nck += strconv.Itoa(code)
spck += strconv.Itoa((code + digits[11-i]) % 10)
}
return strings.Fields("NCK:"+nck + " SPCK:" + spck)
}
func zteB03(imei string) string { //zteB03
var (
key [8]int64
out = ""
pre [16]int64
err error
)
mySum := md5.New()
io.WriteString(mySum, imei)
imeiMD5 := mySum.Sum(nil)
for i,_ := range imeiMD5{
pre[i],err=strconv.ParseInt(fmt.Sprintf("%x", imeiMD5[i]),16,0)
if err != nil{
panic(err)
}
}
for i:=0; i <=7; i++{
key[i] = (((pre[i] + pre[i+8]) & int64(0xFF)*int64(0x09))/int64(0xFF))
out += fmt.Sprintf("%x", key[i])
}
return "NCK:"+out
}
func zteB04(imei string) string { //zteB04
var (
key [8]int64
out = ""
pre [16]int64
err error
)
mySum := md5.New()
io.WriteString(mySum, imei)
imeiMD5 := mySum.Sum(nil)
for i,_ := range imeiMD5{
pre[i],err=strconv.ParseInt(fmt.Sprintf("%x", imeiMD5[i]),16,0)
if err != nil{
panic(err)
}
}
for i:=0; i <=7; i++{
key[i] = (((pre[i] + pre[i+8] + pre[i+4] + 40) & int64(0xFF)*int64(0x09))/int64(0xFF))
out += fmt.Sprintf("%x", key[i])
}
return "NCK:"+out
}