// Made for USArmy cipher coin posted to 2600 Facebook page here:
// https://www.facebook.com/photo.php?fbid=10155132678174317&set=gm.10155597898509522&type=3&theater
// Photo saved here as USArmy_Award_For_Excellence_Lead_From_The_Front_ciphercoin.jpg
$instring = "10001100001011000110110100001101101011001010110111001110100010101000111011101101111010001000110010101110";
$strlen = strlen($instring);
$bytes = $strlen/8;
print "$strlen characters ($bytes 8bit bytes) found.
\n";
while ($count < $strlen){
$count++;
$outstring = bin2asc($instring);
print "$count $instring
\n";
print "$count $outstring
\n";
// shift one to the left
$last = substr($instring, -1);
$short = substr($instring, 0, $strlen-1);
$instring = $last.$short;
};
// shift the array for length($instring).
// bin2asc: https://stackoverflow.com/questions/840457/string-to-byte-binary-arrays-in-php
function bin2asc($bin){
$result = '';
$len = strlen($bin);
for ($i = 0; $i < $len; $i += 8){
$result .= chr(bindec(substr($bin,$i,8)));
}
return $result;
}
?>