By following simple algorithm using ROT-13:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm
From the picture above clearly shows that the ROT-13 every alphabet A will be replaced with the alphabet N, each alphabet A will be replaced with n alphabet. And so on.
example:
COMPUTER (plain text)
XBZCHGRE (cipher text, ROT-13 encryption results)
BfDGLKvI (cipher text, ROT-17 encryption results)
This algorithm repeatedly stated by Julius Caesar to communicate with his commanders.
Application ROT-n in PHP
Quoted from http://php.net/manual/en/function.str-rot13.php ROT-13 can be directly used in the name of the function str_rot13.
Here's an example of its use:
string str_rot13 ( string Here's an example of its use:
$str
)
Performs the ROT13 encoding on the str
argument and returns the resulting string.
The ROT13 encoding simply shifts every letter by 13 places in
the alphabet while leaving non-alpha characters untouched. Encoding and
decoding are done by the same function, passing an encoded string as
argument will return the original version.
<?php echo str_rot13('PHP 4.3.0'); // CUC 4.3.0 ?>
However, we can actually create their own function to ROT-n in PHP. Here's an example of application:
/ * ROT-13, save the file name rot13.php * /
<p>Enter the text to be converted to / from ROT-13</p> <form action="rot13.php" method="get"> <input type="text" name=string> <input type="submit"> </form> <?php function rot13($s) {return !$s?"":strtr($s,"NnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMm", "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz");} if (isset($_GET['string'])) { $string = $_GET['string']; $rot = rot13($string); echo "Conversion result is <b>$rot</b>";
} ?>/ * ROT-17, save the file name rot17.php * /
<p>Enter the text to be converted to / from ROT-17</p> <form action="rot17.php" method="get"> <input type="text" name=string> <input type="submit" name="submit" id="submit" value="Konversi"> </form> <?php function rot17($s) {return !$s?"":strtr($s,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", "RSTUVWXYZABCDEFGHIJKLMNOPQrstuvwxyzabcdefghijklmnopq");} if (isset($_GET['string'])) { $string = $_GET['string']; $rot = rot17($string); echo "Conversion result is <b>$rot</b>"; } ?>
So, good luck