Forum Moderators: coopster

Message Too Old, No Replies

Wanting to write code generator

         

stevenjm

9:23 am on Jul 5, 2011 (gmt 0)

10+ Year Member



Hi, I am wanting to write a php script where a user can type in an imei number and the code will produce a coresponding code based on the bellow algorithm.



(your_imei)=123456789012347
MD5 (“your_imei5e8dd316726b0335″) = 8f 43 ae 1a 33 19 c6 49 cc 57 40 8b 6a 39 2d 6b

8f xor 33 xor cc xor 6a =1a
43 xor 19 xor 57 xor 39 =34
ae xor c6 xor 40 xor 2d =05
1a xor 49 xor 8b xor 6b =b3

1a3405b3 and 1ffffff or 2000000 = 23405B3
hex2dec (23405B3) = 36963763 -> unlock code

same steps for flash code , only:
MD5 (“your_imei97b7bc6be525ab44″) instead of the other MD5

or in python code that may or may not work,

import hashlib

def getCode(imei, salt):
digest = hashlib.md5((imei+salt).lower()).digest()
code = 0
for i in range(0,4):
code += (ord(digest[i])^ord(digest[4+i])^ord(digest[8+i])^ord(digest[12+i])) << (3-i)*8
code &= 0x1ffffff
code |= 0×2000000
return code

imei = "123456789012347"

print getCode(imei, "5e8dd316726b0335")
print getCode(imei, "97b7bc6be525ab44")



Can anybody help me convert this algo to php? much appreciate any help.

I will tell you what it does when finished.

stevenjm

8:04 am on Jul 6, 2011 (gmt 0)

10+ Year Member



Its ok I worked it out myself. Its the algorithm for unlocking huawei usb modems that are simlocked. the algo creates the unlock code using the modems imei number. I wont post the php script here in case it is against forum rules but can pm script if anybody wants a copy.