Skip to content

Instantly share code, notes, and snippets.

@davialexandre
Created July 2, 2012 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davialexandre/3030561 to your computer and use it in GitHub Desktop.
Save davialexandre/3030561 to your computer and use it in GitHub Desktop.
Security lvl Blonde
<?php
class Encrypt
{
function Encrypt()
{
$this->word = "";
}
function bytexor($a,$b,$l)
{
$c="";
for($i=0;$i<$l;$i++)
{
$c.=$a{$i}^$b{$i};
}
return $c;
}
function binmd5($val)
{
return(pack("H*",md5($val)));
}
function md5_decrypt($msg,$heslo)
{
$key = $heslo;
$sifra = "";
$key1 = $this->binmd5($key);
while($msg)
{
$m = substr($msg,0,16);
$msg = substr($msg,16);
$sifra .= $m = $this->bytexor($m,$key1,16);
$key1 = $this->binmd5($key.$key1.$m);
}
return $sifra;
}
function md5_encrypt($msg,$heslo)
{
$key = $heslo;
$sifra = "";
$key1 = $this->binmd5($key);
while($msg)
{
$m = substr($msg,0,16);
$msg = substr($msg,16);
$sifra .= $this->bytexor($m,$key1,16);
$key1 = $this->binmd5($key.$key1.$m);
}
return $sifra;
}
function filter($sifra,$inverso=false)
{
if($inverso)
{
$old = array('#');
$new = array('+');
$word = str_replace($old,$new,$sifra);
$word2 = base64_decode($word);
return $word2;
}
$word = base64_encode($sifra);
$old = array('+');
$new = array('#');
return str_replace($old,$new,$word);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment