Created
July 2, 2012 02:23
-
-
Save davialexandre/3030561 to your computer and use it in GitHub Desktop.
Security lvl Blonde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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