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
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.Code:// Create a Random Generator
srand((double)microtime()*1000000); // Seed the Random Generator
$strCharNumber = rand(102,106); // Pics a number between 102 and 106
2) Add this character to our final string output
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.Code:$strcode = chr($strCharNumber); // Add char to ending String
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.
4) In my code I also converted to hex but you can leave this step out if you like.Code:// For Loop to convert each char into ascii then increase number
for ($i = 0; $i < strlen($name); $i++) {
$strChar = ord($name[$i]) + $strCharNumber;
5) Add the string to the final string and close the for loop.Code:$strChar = bin2hex(chr($strChar));
I've also attached a working copy of the PHP script. Let me know if you have any questions!Code:$strcode = $strcode & $strChar;
}
?>
Void
I found my "Caesars Cipher" I made a while ago.
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;
}
?>
I hope this will gonna help![]()
I was looking for something similar a frew weeks ago. Thanks !
Thank you, that was really helpful!![]()
Not to bad mate. Is there anyway to retrieve the encryption?
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!
You have to know the shift value. In void's example it is between 102 and 106.
In John's example it defaults to 3 but could be whatever the coder sets it to.Code:$strCharNumber = rand(102,106);
Oh OK thanks Jordan. How does MD5 work then? How come it's so hard to crack?
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!
MD5 is a one-way hash algorithm, however, these encryption schemes above just move the ASCII value of a character. For instance, it will take the Char "a" and convert it to the ASCII value of 97, add 3 to it to make 100 and convert it back to a char (100 = d). It is a fairly simple encryption scheme and can be cracked fairly easy.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks