In BitTorrent v2 there's pieces root key (string) which has root sha256 of a file encoded in binary form, in documentation there's written:
"pieces root" is the the root hash of a merkle tree with a branching factor of 2, constructed from 16KiB blocks of the file. The last block may be shorter than 16KiB. The remaining leaf hashes beyond the end of the file required to construct upper layers of the merkle tree are set to zero. As of meta version 2 SHA2-256 is used as digest function for the merkle tree. The hash is stored in its binary form, not as human-readable string.
I need to extract this hash to use it on my torrent tracker, so in info web page users could see original hashes of files of torrent, how do I do that? How could I decode that binary string and I don't know if those are concatenation of all piece hashes.
PHP or C is preferred or maybe some docs. I'm a noob regarding encoding, so please explain thoroughly. Thanks a ton!!
I tried unpack() function, but I'm missing something.