import base64
# Decoding Byte
byte = base64.decodebytes(b'Gcmtb8==')
# Getting an int from the byte
Number = int.from_bytes(byte, byteorder="big")
# From Int to bytes again (For Testing & confirmation)
Decoded = int.to_bytes(Number,4,byteorder="big")
# Encoding back to base64_urlsafe
encode = base64.urlsafe_b64encode(Decoded)
print("""
Test 1
Decoded to byte: {}
Number from byte: {}
Byte from number: {}
Output: {}
""".format(byte,Number,Decoded,encode))
Output Test 1 Decoded to byte: b'\x19\xc9\xado' Number from byte: 432647535 Byte from number: b'\x19\xc9\xado' Output: b'Gcmtbw==' | The Output I want Test 1 Decoded to byte: b'\x19\xc9\xado' Number from byte: 432647535 Byte from number: b'\x19\xc9\xado' Output: b'Gcmtb8=='