Skip to content

Instantly share code, notes, and snippets.

@MightyPork
Created October 18, 2015 12:47
Show Gist options
  • Save MightyPork/944ccf8fbe7a35bf95aa to your computer and use it in GitHub Desktop.
Save MightyPork/944ccf8fbe7a35bf95aa to your computer and use it in GitHub Desktop.
<?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