I found my "Caesars Cipher" I made a while ago.
PHP Code:
<?php
function CaesarCipher($str, $offset=3) {
$max = strlen($str);
for($i = 0; $i < $max; $i++){
//if the letter is upper case, keep it uppercase
if(ord($str[$i]) >= 65 && ord($str[$i]) <= 90){
if((ord($str[$i])+$offset) > 90) {
$crypt .= chr(65+((ord($str[$i])+$offset)-91));
} else {
$crypt .= chr(ord($str[$i])+$offset);
}
}
//if the letter is lower case, keep it lower case
else if(ord($str[$i]) >= 97 && ord($str[$i]) <= 122){
if((ord($str[$i])+$offset) > 122) {
$crypt .= chr(97+((ord($str[$i])+$offset)-123));
} else {
$crypt .= chr(ord($str[$i])+$offset);
}
}
else {
die("You can only use letters.");
//$crypt .= chr(ord($str[$i])+$offset);
}
}
//$crypt = strtoupper($crypt);
echo $crypt;
}
?>