Here is the sample code in JS :
function toHexString(bytes) {
return bytes.map(function(byte) {
return ("00" + (byte & 0xFF).toString(16)).slice(-2);
}).join('');
}
input -> Buffer.from("333138383223633D77DB", 'hex')
output -> 333138383223630770
Here is what I have tried so far in Python
def toHexString(byteArray):
return ''.join('{:02x}'.format(x) for x in byteArray)
input -> bytearray.fromhex("333138383223633D77DB")
output -> 333138383223633d77db
I think the logic is correct but does not know what is wrong
My expectation result of the Python code should be similar to the result of JS code.
I would like to ask how should I update the python code to get the exact result as JS code
toHexStringdoesn't do what its name suggests.