View Single Post
  #2 (permalink)  
Old 10-17-2007, 10:11 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,817
Last Blog:
Passwords
Credits: 52
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
Send a message via AIM to John
Default

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;
}

?>
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Reply With Quote