bdecode first test

This commit is contained in:
mykola2312 2022-03-18 12:49:30 +02:00
parent 53b4985869
commit 31aa07530a

View file

@ -42,23 +42,23 @@ function bencode($var)
do_error('bencode wrong data type'); do_error('bencode wrong data type');
} }
} }
/*
function bdecode($enc) function bdecode($enc)
{ {
if ($endPos = strpos($enc, 'e') == false) { $result = null;
// string $encLen = strlen($enc);
} for ($i = 0; $i < $encLen; $i++)
if (!$endPos) {
return null;
}
$type = substr($enc, 1, 1);
$data = substr($enc, 1, $endPos - 1);
switch ($type)
{ {
case 'i': return intval($data); $type = substr($enc, $i, 1);
if ($type == 'i') {
$start = ++$i;
$end = strpos($enc, 'e', $i);
$result = substr($enc, $start, $end - $start);
$i = $end;
continue;
} }
}
return $result;
} }
*/
?> ?>