Created
May 31, 2015 02:50
-
-
Save rocketeerbkw/159a3c4986f9a835d531 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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