I'm converting an old node.js lib into python and can't reproduce the behaviour of Buffer.toString() in python.
this lib is use in a node 6.0.0 environment
I did take a look at this node issue, but i don't understand if it's linked to my problem.
js function:
const KDF_PARTY_V = Buffer.from('E6F8C08930597B47472620568D207A23E4FCEF4B3F0AA3DC26FF369C622C6E1D', 'hex').toString('binary')
// The SHA-256 hash of your ID string literal; 32 bytes in size.
console.log(KDF_PARTY_V)
output:
æøÀ0Y{GG& V z#äüïK?
£Ü&ÿ6b,n
python equivalent:
kdf_v = memoryview(bytes.fromhex('E6F8C08930597B47472620568D207A23E4FCEF4B3F0AA3DC26FF369C622C6E1D')).tobytes().decode('latin-1')
print(kdf_v)
the output (badly shown by stack)
æøÀ‰0Y{GG& V z#äüïK?
£Ü&ÿ6œb,n
My actual console message:
maybe i sould use something different than latin-1 and utf-8 ?
it was just a console caracter encoding mistake
when looking at the binary data itself the python version is the same as the js one so:
kdf_v = bytes.fromhex(merchant_id).decode('latin1')
work perfectly
@AKX i do need to have the variable in str format, because i use it in a concatenation and the result of it in a sha256 digest