Skip to content

Instantly share code, notes, and snippets.

@syst3mw0rm
Created March 10, 2013 16:12
Show Gist options
  • Select an option

  • Save syst3mw0rm/5129170 to your computer and use it in GitHub Desktop.

Select an option

Save syst3mw0rm/5129170 to your computer and use it in GitHub Desktop.
<?php
// h4x0r's ultimate encryption algorithm
// I put the string to be encrypted here
$str = 'aaaaaaaaaaaaaaaaaa';
// I convert the string to ASCII
// I generate a random key in between 10 and the maximum value of the ASCII's
// So the key is different everytime B)
$max = 255;
$key = rand(10,$max);
// Multiply the key by 101 to increase complexity
$key = 101*$key;
$key = 1010;
//$key guess!!
// Using this key I encrypt my string using the cool algorithm below
echo "\n\n";
$answer = array(168, 232, 100, 162, 135, 179, 112, 100, 173, 206, 106, 123, 106, 195, 179, 157, 123, 173);
for($kk=10; $kk<=$max; $kk=$kk+1) {
$key = $kk*101;
echo "########################### For key = $key #################################: \n\n";
$iss = 0;
$stra = " ";
for($i=0;$i<strlen($str);$i++) {
$is = 0;
for($c=65;$c<=122;$c++) {
$x = $c;
$am = ($key+$x)/2;
$gm = sqrt($key*$x);
$enc = $am + $gm;
$encrypt = floor($enc)%255; // This is the final encrypted number
if($encrypt == $answer[$i]) {
$ar[$i] = $c;
$is = 1;
$stra += $c + " ";
break;
}
else {
continue;
}
}
if($is==0) {
// this place wasn't filled using this particular key, so increase the key.
break;
}
if($i == strlen($str)-1) {
// last spot was filled!!
$iss = 1;
}
}
if($iss) {
echo "Print answer : $stra\n\n";
print_r($ar);
for($i=0;$i<strlen($str);$i++){
echo chr($ar[$i]);
}
break;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment