note 32634 added to function.md5
| From: | hkmaly at matfyz dot cz | Date: | Tue, 03 Jun 2003 16:01:29 +0000 |
| Subject: | note 32634 added to function.md5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49629@lists.php.net to get a copy of this message | ||
HOWTO use MD5 to crypt (&decrypt) string (Same routine for crypt and decrypt. Same time and
password requied.) (hkmaly@matfyz.cz, GPL):
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 crypt($msg,$pass,$time)
{
$key=$pass.$time;$sifra="";
$key1=binmd5($key);
while($msg) {
$m=substr($msg,0,16);
$msg=substr($msg,16);
echo ".";
$sifra.=bytexor($m,$key1,16);
$key1=binmd5($key,$key1,$m);
}
echo "\n";
return($sifra);
}
----
Manual Page -- http://www.php.net/manual/en/function.md5.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32634
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32634&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32634&report=yes