Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert IMEI-SV to IMEI
# -*- coding: utf-8 -*-
# @Author: khsing
# @Date: 2017-05-08 17:52:55
# @Last Modified by: khsing
# @Last Modified time: 2017-05-08 18:38:08
import sys
import hashlib
def checkImeisv(imeisv):
return len(imeisv) == 16
def doubleOther(i):
x = i[0]
y = i[1]
if (x%2) == 0:
return str(int(y)*2)
else:
return y
def convert(imeisv):
_imei = imeisv[:-2]
imei = map(doubleOther, enumerate(reversed(_imei)))
checknum = 10 - (sum([int(i) for i in ''.join(reversed(imei))])%10)
if checknum == 10:
checknum = 0
return _imei + str(checknum), checknum
def main():
with open(sys.argv[1]) as fd:
for line in fd:
line = line.strip()
if checkImeisv(line):
print(hashlib.md5(convert(line)[0]).hexdigest())
if __name__ == '__main__':
main()
@DaniDiaz71

This comment has been minimized.

Copy link

DaniDiaz71 commented Jun 18, 2019

Does not work :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.