-1

I am creating a python api which will receive a hexadecimal data like below:

AA213FD51B3801043FBC

I have to further decode to make it human readable string which I can do easily. Normally I have designed flask api to receive json data like below:

@app.route('/', methods=['POST'])
def hello():
    raw_data = request.get_json()

but not sure how to receive hex data. Can anyone please suggest any idea. Thanks

S Andrew
  • 5,592
  • 27
  • 115
  • 237

1 Answers1

1

you can receive hexdata as a string and then use the int function to turn the value into a number with base 10

int('AA213FD51B3801043FBC',16) 

to convert it to a hex number with base 16 apply

hex(int('AA213FD51B3801043FBC',16)) 

you can then use it for hex calculations e.g.

hex(int('AA213FD51B3801043FBC',16)) + hex(10)
Sacagawea
  • 31
  • 5