Thursday, October 16, 2008

The str_rot13() function

This function performs ROT13 encoding on a string.

Syntax: str_rot13(string);

Example input:

$str1="This is a simple program number 1";
$str2= str_rot13($str1);
echo $str2;
echo "
";
echo $str3= str_rot13($str2);

Example output:

Guvf vf n fvzcyr cebtenz ahzore 1
This is a simple program number 1

What is ROT13?

A ROT13 enoding algorithm moves every character in a string 13 places forward. Numbers and special characters, however, are untouched.


Another interesting fact about the ROT13 algorithm is that the same algorithm could be used for encoding as well as decoding as you’d understand when you analyze the example.

myLot User Profile

No comments: