Created
May 29, 2017 22:17
-
-
Save thurask/ebc4336bceda1f29ae3ac7ce4b745ad2 to your computer and use it in GitHub Desktop.
Convert BB PIN to (partial) serial and vice versa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pin2serial(pin): | |
serial = str(int(pin, 16)).rjust(10, "0").ljust(12, "X") | |
return "{0}-{1}-{2}".format(serial[:4], serial[4:8], serial[8:]) | |
def serial2pin(serial): | |
serial = serial.replace("-", "", 2) | |
return format(int(serial[:-2]), "02x").upper() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment