Page 1 of 1

Website challenge!

Posted: Wed May 19, 2004 6:50 pm
by Joe
I have recently been trying to make a small decryption challenge for my site where the user has to work out the encryption method used. To help people out I have developed a tool which takes a string and subtracts 2 away from each character (Ascii shift). The problem is that I cannot get it to work on the whole string but a single character shift is easy. Any help appreciated!

CODE
====
$string = $_POST['encrypt'];
for ($i=0; $i<strlen($string); $i++)
{
$enc = ord($string) - 2;
$enc1 = chr(substr($enc),$i);
echo $enc1;
}


Regards


Joe 8)

Posted: Wed May 19, 2004 7:36 pm
by feyd

Code: Select all

<?php
for($x = 0; $x < strlen($string); $x++)
{
$string{$x} = chr(ord($string{$x})-2);
}
?>

Posted: Thu May 20, 2004 11:16 am
by Joe
Thanks alot man that worked perfect.

Joe 8)