I want to make simple encryption with rot13, but i don't want use function str_rot13(), because I want add numbers on it and I think str_rot13() isn't supported. I have found code like this and want to edit, but I don't know how
<?php
$string = "Hello World 123";
for ($i = 0, $j = strlen( $string); $i < $j; $i++)
{
// Get the ASCII character for the current character
$char = ord( $string[$i]);
// If that character is in the range A-Z or a-z, add 13 to its ASCII value
if( ($char >= 65 && $char <= 90) || ($char >= 97 && $char <= 122))
{
$char += 13;
// If we should have wrapped around the alphabet, subtract 26
if( $char > 122 || ( $char > 90 && ord( $string[$i]) < 97))
{
$char -= 26;
}
}
echo chr( $char);
}
?>
this code have result "Uryyb Jbeyq 123". What I want is add number 0-9 on it, so encryption become rot18 -> a-z0123456789. Result of this so become "Zw336 E693v JKL"
Aucun commentaire:
Enregistrer un commentaire