, - : bool $raw_output PHP: sha1, "true".
BDecode/DEncode . , Trackon, - .
, PHP - , - correct :
include('./path/to/BDecode.php');
include('./path/to/BEncode.php');
function getHash($torFile){
$tfile = BDecode(file_get_contents($torFile));
$infohash = sha1(BEncode($tfile["info"]), TRUE);
return urlencode($infohash);
}
:
$hash = getHash('./path/to/.torrent');
Hope this helps someone. I was still scratching my head after reading many posts on how to get the right hash of information. I understand why this was not mentioned anywhere, but this argument was added in PHP 5. If you are not using PHP 5, you will have to convert the sha1 hash to the source binary after calculating it.
source
share