Text
|
|
|
|
<?php /*ROT13 function - a function to encode and decode text strings
using the popular ROT13 method.
Brett Burridge (brett@brettb.com)
The function is called using something like:
print ROT13("Hello World");
Note that ROT13 does not encrypt strings, so do not use it if security is an issue
An ASP and JavaScript version of the function is available from:
http://www.aspwatch.com/c/199934/d5D41863A588511D3ADCA00A0C9E95208.asp
*/
Function ROT13($rot13text) {
$rot13text_rotated = "";
for ($i = 0; $i <= strlen($rot13text); $i++) {
$k = ord(substr($rot13text, $i, 1));
if ($k >= 97 and $k <= 109) {
$k = $k + 13;
} elseif ($k >= 110 and $k <= 122) {
$k = $k - 13;
} elseif ($k >= 65 and $k <= 77) {
$k = $k + 13;
} elseif ($k >= 78 and $k <= 90) {
$k = $k - 13;
}
$rot13text_rotated = $rot13text_rotated . Chr($k);
}
return $rot13text_rotated;
}
?>
|
|
|
Usage Example
|
print ROT13("Hello World");
|
|
|
Rate This Script
|
|
|
|