Skip to content

Instantly share code, notes, and snippets.

@thurask
Created May 29, 2017 22:17
Show Gist options
  • Save thurask/ebc4336bceda1f29ae3ac7ce4b745ad2 to your computer and use it in GitHub Desktop.
Save thurask/ebc4336bceda1f29ae3ac7ce4b745ad2 to your computer and use it in GitHub Desktop.
Convert BB PIN to (partial) serial and vice versa
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