Thursday, April 2, 2015

Rot 5 Caesar Ciphers for numbers - PHP Snippet

Rot 5 Caesar Ciphers for numbers - PHP Snippet

ROT5 covers the numbers 0-9.


function rot5($string){ 
for ($i = 0, $j = strlen( $string); $i < $j; $i++)
{
$char = ord($string[$i]);
if( ($char >= 48 && $char <= 57))
{
$char += 5;
if( $char > 57)
{
$char -= 10;
}
}
$string[$i] = chr($char);
}
return $string;
}
Disqus Comments