Skip to content

Instantly share code, notes, and snippets.

@unique1984
Created February 14, 2024 20:24
Show Gist options
  • Save unique1984/0f0356c703a3de8ff7ab6b08d8e4d252 to your computer and use it in GitHub Desktop.
Save unique1984/0f0356c703a3de8ff7ab6b08d8e4d252 to your computer and use it in GitHub Desktop.
Binary To String & String To Binary conversion 8bit
<?php
if(empty($argv[1])) {
die;
}
if($argc > 2) {
for ($i = 1; $i < $argc; $i++) {
echo chr(bindec($argv[$i]));
}
echo "\n";
die;
}
$dec=bindec($argv[1]);
echo chr($dec) . "\n";
<?php
if(empty($argv[1])) {
die;
}
$str=null;
for ($i = 1; $i < $argc; $i++) {
$str .= $argv[$i]." ";
}
$str = str_split($str);
//print_r($str);
if ($str[count($str) - 1] == " ") {
unset($str[count($str) - 1]);
}
foreach ($str as $val) {
echo decbin(ord($val)) . " ";
}
echo "\n";
die;
@unique1984
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment