<?php
require 'bencoded.php';
$be = new BEncoded;
$be->NewNode('dict', 'child');
$be->Set('child/key', 'value');
$be->Set('child/_key', '_val');
echo $be->ToString(); // => d5:childd4:_key4:_val3:key5:valueee
$be->FromFile('1.torrent');
// or this, which is the same:
//$be = new BEncoded(file_get_contents('1.torrent'));
echo $be->InfoHash(); // => DFE39EFFF439B78BB2DD2CAEB69B72ACFE660710
|