User Tools

Site Tools


project:freakcard:parse_alpha.php
parse_alpha.php
<?php
 
$input = $argv[1];
 
$start = strpos($input, '1010001'); /* Start Sentinel */
$to_parse = substr($input, $start); // strip leading zeros
$byte = 0x0;
 
$pos = 0;
$end_sentinel = false;
 
while ($pos < strlen($to_parse)) {
    $byte = bindec(strrev(substr($to_parse, $pos, 7)));
 
    $byte &= 0x3f;
    $byte += 0x20;
 
    echo chr($byte);
 
    if ($end_sentinel) {
        break;
    }
    if (chr($byte) == '?') { /* End Sentinel */
        $end_sentinel = true;
    }
    $pos += 7;
}
 
echo "\n";
project/freakcard/parse_alpha.php.txt · Last modified: 2011/10/04 14:13 by lukash