Skip to content

Instantly share code, notes, and snippets.

@rocketeerbkw
Created May 31, 2015 02:50
Show Gist options
  • Save rocketeerbkw/159a3c4986f9a835d531 to your computer and use it in GitHub Desktop.
Save rocketeerbkw/159a3c4986f9a835d531 to your computer and use it in GitHub Desktop.
<?php
$encoded = [
['55', '66', '78', '80', '00', 'FF', 'FF', '00'],
];
$decoded = '';
foreach ($encoded as $hex_word) {
$bin_word = [];
foreach ($hex_word as $hex) {
$bin = str_pad(base_convert($hex, 16, 2), 8, '0', STR_PAD_LEFT);
$bin_word[] = str_split($bin, 1);
}
for ($i = 7; $i >= 0; $i--) {
$new_bin = '';
for ($j = 7; $j >= 0; $j--) {
$new_bin .= $bin_word[$j][$i];
}
echo chr(base_convert($new_bin, 2, 10));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment