1

I'm trying to convert a hashed block number "30054a" into readable format but I'm getting logs something like this:

0J

For another hashed value:

Y����#�(�J�d��F,ĦJ/

I'm using the following code on my NodeJS server:

const util = require('ethjs-util'); const value = util.toAscii('30054a'); console.log(value);

I had even tried toUtf8. I'm using ethjs library.

Where am I wrong?

1 Answer 1

1

You said the value is "hashed," but I think you're just looking at the hexadecimal number?

If so, parseInt('30054a', '16') == 3147082. 3147082 is the decimal representation of the hexadecimal number 0x30054a.

If you actually have a value that's been hashed, there's generally no way to reverse that process. (A cryptographic hash function is designed to be one-way.)

6
  • What about hexadecimal string, object or function? May 2, 2018 at 5:03
  • I tried converting this cded53d631ce4a38a1f90d59e5f2f9c023cd28c64aa66488e9462cc4a64a032f using web3.toAscii(). It returned - ÍíSÖ1ÎJ8¡ù YåòùÀ#Í(ÆJ¦déF,ĦJ/ May 2, 2018 at 5:35
  • I didn't say anything about web3.toAscii. That would only be appropriate if the value you have came from an ASCII string. Where did those values come from?
    – user19510
    May 2, 2018 at 12:25
  • I called the etherscan API of event logs. All the key's field are in hexadecimal format. How can I convert it in readable format? May 2, 2018 at 13:34
  • Can you suggest any accurate article or course which explains the whole concept ot hexa to big number to whatever? May 2, 2018 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.