1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

Merge pull request #322 from lunzhiPenxil/patch-1

修正GenIMEI
This commit is contained in:
Mrs4s 2023-03-16 07:15:27 +08:00 committed by GitHub
commit 1c6552c19f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,14 +92,14 @@ func GenIMEI() string {
randGen := rand.New(rand.NewSource(time.Now().UnixNano())) randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < 14; i++ { // generating all the base digits for i := 0; i < 14; i++ { // generating all the base digits
toAdd := randGen.Intn(10) toAdd := randGen.Intn(10)
fmt.Fprintf(&final, "%d", toAdd) // printing them here!
if (i+1)%2 == 0 { // special proc for every 2nd one if (i+1)%2 == 0 { // special proc for every 2nd one
toAdd *= 2 toAdd *= 2
if toAdd >= 10 { if toAdd >= 10 {
toAdd = (toAdd % 10) + 1 toAdd = (toAdd % 10) + 1
} }
} }
sum += toAdd sum += toAdd // and even add them here!
fmt.Fprintf(&final, "%d", toAdd) // and even printing them here!
} }
ctrlDigit := (sum * 9) % 10 // calculating the control digit ctrlDigit := (sum * 9) % 10 // calculating the control digit
fmt.Fprintf(&final, "%d", ctrlDigit) fmt.Fprintf(&final, "%d", ctrlDigit)