diff --git a/client/global.go b/client/global.go index cf90ad48a..7cbefa250 100644 --- a/client/global.go +++ b/client/global.go @@ -92,8 +92,8 @@ func GenIMEI() string { randGen := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < 14; i++ { // generating all the base digits toAdd := randGen.Intn(10) - fmt.Fprintf(&final, "%d", toAdd) // printing them here! - if (i+1)%2 == 0 { // special proc for every 2nd one + final.WriteString(strconv.Itoa(toAdd)) + if (i+1)%2 == 0 { // special proc for every 2nd one toAdd *= 2 if toAdd >= 10 { toAdd = (toAdd % 10) + 1 @@ -102,7 +102,7 @@ func GenIMEI() string { sum += toAdd // and even add them here! } ctrlDigit := (sum * 9) % 10 // calculating the control digit - fmt.Fprintf(&final, "%d", ctrlDigit) + final.WriteString(strconv.Itoa(ctrlDigit)) return final.String() } diff --git a/client/internal/auth/qimei.go b/client/internal/auth/qimei.go index 5694330d7..627ca14c4 100644 --- a/client/internal/auth/qimei.go +++ b/client/internal/auth/qimei.go @@ -5,6 +5,7 @@ import ( "crypto/aes" "crypto/cipher" "crypto/md5" + crand "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/base64" @@ -42,7 +43,7 @@ func (info *Device) RequestQImei() { // init rsa key and aes key publicKey := initPublicKey() - encryptedAesKey, _ := rsa.EncryptPKCS1v15(rand.New(rand.NewSource(time.Now().UnixNano())), publicKey, []byte(cryptKey)) + encryptedAesKey, _ := rsa.EncryptPKCS1v15(crand.Reader, publicKey, []byte(cryptKey)) encryptedPayload := aesEncrypt(payload, []byte(cryptKey)) diff --git a/topic/feed.go b/topic/feed.go index 56cd2f5a6..f48862d67 100644 --- a/topic/feed.go +++ b/topic/feed.go @@ -159,7 +159,7 @@ func DecodeFeed(p *channel.StFeed) *Feed { f.Contents = append(f.Contents, &TextElement{Content: c.TextContent.Text.Unwrap()}) } if c.EmojiContent != nil { - id, _ := strconv.ParseInt(c.EmojiContent.Id.Unwrap(), 10, 64) + id, _ := strconv.ParseInt(c.EmojiContent.Id.Unwrap(), 10, 32) f.Contents = append(f.Contents, &EmojiElement{ Index: int32(id), Id: c.EmojiContent.Id.Unwrap(),