Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: allthatremains on October 29, 2013, 06:21:47 PM



Title: Help with hashes
Post by: allthatremains on October 29, 2013, 06:21:47 PM
Hi,

I used znort987's github blockchain parsing repo to get the following output on blocks:

3   \0\0\0\0UԺ@>o 5t,bFDI   1231470173
4   \0\0\0\0NUɢ\   Y֋"HJ   1231470988
5   \0\0\0\0rb1]6V\   {* "3   1231471428
6   \0\0\0\001 75i Z򤾂U;*vӢ܏w   1231471789
7   \0\0\0\0ql+_F䅲YJ ̽TAȔD   1231472369

The middle column is a block's hash. How can I change this hash into alphanumeric characters? E.g.   "hash":"0000000000000001bfd57dad6bad2a345a47d6f3b4eb91925a6084016c1c19bc",


Thanks!


Title: Re: Help with hashes
Post by: Rannasha on October 29, 2013, 08:05:38 PM
Convert each byte to a hexadecimal representation. For each byte b of the hash, compute b / 16 and b % 16 as the two hexadecimal digits that represent that byte.


Title: Re: Help with hashes
Post by: allthatremains on October 29, 2013, 09:24:29 PM
That sounds correct in principle, but how can I apply those operations to the string:

\0\0\0\0UԺ@>o 5t,bFDI

?

Thanks!


Title: Re: Help with hashes
Post by: DannyHamilton on October 29, 2013, 09:28:15 PM
znort987's github blockchain parsing repo

Link please?


Title: Re: Help with hashes
Post by: allthatremains on October 29, 2013, 09:30:47 PM
https://github.com/znort987/blockparser


Title: Re: Help with hashes
Post by: allthatremains on October 30, 2013, 04:31:06 PM
Does anyone have a method for transforming these type of characters into alphanumeric strings?


Title: Re: Help with hashes
Post by: Remember remember the 5th of November on October 30, 2013, 06:39:52 PM
Does anyone have a method for transforming these type of characters into alphanumeric strings?
Yeah, true. You would need to get the actual bytes instead or use a modified blockparser that outputs the hash instead of those characters.