python fsb795 leading serial number zero



  • Hello, everyone. I work with skilled certificate files, one of the tasks is to get a serial number. Certificates are available, starting from 0

    введите сюда описание изображения

    When I determine the serial number with a python, I lose the lead zero.

    cert = fsb795.Certificate(filename)
    if (cert.pyver == ''):
        exit(-1)
    print( '{0:x}'.format(cert.serialNumber()) )
    

    cert.serialNumber() : 244779530423518144939779859097793331

    Programme withdrawal: 1d76da04fd9aea00000033603e80002

    Must be: 01d76da04fd9aea00000033603e80002



  • Let's move the bikes to the number:

    s=int.from_bytes(bytes.fromhex('01d76da04fd9aea00000033603e80002'),'big')
    

    s.bit_length()

    24477953042351849397798590977933314 long 121 battles, rounded in whites:

    import math
    math.ceil(s.bit_length()/8)

    16 Byte. We're moving back to HEX.

    s.to_bytes(math.ceil(s.bit_length()/8),'big').hex()

    '01d76da04fd9aea00000033603e80002'


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2