Lost Password?

  #1 (permalink)  
Old 10-18-2006, 09:26 AM
Void's Avatar   
Void Void is offline
Programming Expert
 
Join Date: Jun 2006
Posts: 410
Rep Power: 10
Void is on a distinguished road
Default PHP Code: Simple Encryption Algorithm

This is a very simple Encryption Algorithm that uses the Caesar Shift Decoder (also called the Caesar Cipher).

The encryption is not limited to 25 characters though but is limited to the ASCII table moving each character a random amount of numbers forward.

Here is how it works:

1) Generate a Random Number

PHP Code:
// Create a Random Generator
srand((double)microtime()*1000000); // Seed the Random Generator
$strCharNumber rand(102,106); // Pics a number between 102 and 106 
This code will be the variable for how many characters the encryption scheme will be moved forward. As you can see, it is between 102 and 106.

2) Add this character to our final string output

PHP Code:
$strcode chr($strCharNumber); // Add char to ending String 
This allows us to grab that character and decrypt the entire string. This makes the code very unsecure as anyone that knows that is the decoding character can decode this message.

3) Encode the rest of the string. Lets say you received a [b]g[/g] which is 103 ascii value. For each character you would get the ascii value and move it up 103 values in the ascii table.

PHP Code:
// For Loop to convert each char into ascii then increase number
for ($i 0$i strlen($name); $i++) {
        
$strChar ord($name[$i]) + $strCharNumber
4) In my code I also converted to hex but you can leave this step out if you like.

PHP Code:
        $strChar bin2hex(chr($strChar)); 
5) Add the string to the final string and close the for loop.

PHP Code:
        $strcode $strcode $strChar;
}
?> 
I've also attached a working copy of the PHP script. Let me know if you have any questions!
Attached Files To view attachments your post count must be 1 or greater. Your post count is 0 momentarily.
__________________
Void
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #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,347
Last Blog:
PHP Function Overloadi...
Rep Power: 50
John is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of light
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-19-2007, 10:25 AM
technology technology is offline
Newbie
 
Join Date: Oct 2007
Posts: 1
Rep Power: 0
technology is on a distinguished road
Default thanks

I hope this will gonna help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-05-2008, 12:45 PM
dfactor dfactor is offline
Newbie
 
Join Date: Apr 2008
Posts: 1
Rep Power: 0
dfactor is on a distinguished road
Default Re: thanks

Quote:
Originally Posted by technology View Post
I hope this will gonna help
This looks like it will work for me!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-19-2008, 09:52 AM
yolau yolau is offline
Newbie
 
Join Date: Apr 2008
Posts: 4
Rep Power: 0
yolau is on a distinguished road
Default Re: PHP Code: Simple Encryption Algorithm

I was looking for something similar a frew weeks ago. Thanks !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginners Guide To PHP: *Tutorial* renlok PHP Tutorials 3 04-22-2008 03:20 PM
Where to Put PHP Code clookid PHP Tutorials 1 01-11-2007 08:44 PM


All times are GMT -5. The time now is 06:06 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads