From Buffer("string", "hex) to string JS

46 Views Asked by At

I'm writing a function to reduce the key by 2 times. The function accepts a key in the following form:

Buffer.from('0xe581d529cc69816e768432a8aa09178470c9b1e703951f4a85e0dab7d8008e2a9e9e179', 'hex')

so that I can reduce the key I need to convert it to a string. The toString() or toString('hex') method do not work.

I also tried using sha256 encryption for the key, but when I called the function with different keys I still got the same value after hashing.

Checking the value of a key or its length using console.log() showed that the length was 0, but when printing the key it did not output anything.

0

There are 0 best solutions below