Created
October 18, 2015 12:47
-
-
Save MightyPork/944ccf8fbe7a35bf95aa to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
dehexify("414D415A494E47"); | |
hexify("If you can read this, you are not special. You just know ASCII."); | |
function dehexify($x) { | |
$buf=''; | |
for ($i = 0; $i < strlen($x); $i++) | |
{ | |
if ($x[$i] == ' ') { | |
echo ' '; | |
$buf = ''; | |
} else { | |
$buf .= $x[$i]; | |
if (strlen($buf) == 2) { | |
echo chr(hexdec($buf)); | |
$buf = ''; | |
} | |
} | |
} | |
echo "\n"; | |
} | |
function hexify($x) | |
{ | |
for ($i = 0; $i < strlen($x); $i++) | |
{ | |
if ($x[$i] == ' ') { echo ' '; continue; } | |
echo strtoupper(dechex(ord($x[$i]))); | |
} | |
echo "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment