Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
showcaller request/response encoder and decoder
<?php
$d = Decode("ezL2hGG2gbMjQmEsJpQzZoTic2AveaVvfKQiPnwhfR==");
print($d . "\n");
$e = Encode($d);
print($e . "\n");
function Decode($str)
{
$str = str_split($str);
$n = '';
for ($i = 0; $i < count($str); $i++) {
$charAt = ord($str[$i]);
if (($charAt >= 48 && $charAt <= 57) || (($charAt >= 65 && $charAt <= 90) || ($charAt >= 97 && $charAt <= 122))) {
$i2 = $charAt - ($i % 5);
$charAt = ($i2 < 48 ? (122 - (48 - $i2)) + 1 : ($charAt < 65 || $i2 >= 65 ? ($charAt < 97 || $i2 >= 97 ? $i2 : (90 - (97 - $i2) ) + 1 ) : (57 - (65 - $i2) ) +1 ));
$n .= chr($charAt);
}
}
return base64_decode($n);
}
function Encode($str)
{
$str = base64_encode($str);
$str = str_split($str);
$n = '';
for ($i2 = 0; $i2 < count($str); $i2++) {
$c2 = ord($str[$i2]);
if (($c2 >= 48 && $c2 <= 57) || (($c2 >= 65 && $c2 <= 90) || ($c2 >= 97 && $c2 <= 122))) {
$i3 = ($i2 % 5) + $c2;
if ($i3 > 122) {
$c2 = (($i3 - 122) + 48) - 1;
} else if ($c2 <= 90 && $i3 > 90) {
$c2 = (($i3 - 90) + 97) - 1;
} else if ($c2 > 57 || $i3 <= 57) {
$c2 = $i3;
} else {
$c2 = (($i3 - 57) + 65) - 1;
}
}
$n .= chr($c2);
}
return $n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment