<?PHPclassMypass {Static functionEncrypt$data,$key){ $key=MD5($key); $x= 0; $len=strlen($data); $l=strlen($key); for($i= 0;$i<$len;$i++){ if($x==$l){ $x= 0; } $char.=$key{$x}; $x++; } for($i= 0;$i<$len;$i++){ $str.=CHR(Ord($data{$i}) + (Ord($char{$i}))% 256); } return Base64_encode($str); } Static functionDecrypt$data,$key){ $key=MD5($key); $x= 0; $data=Base64_decode($data); $len=strlen($data); $l=strlen($key); for($i= 0;$i<$len;$i++) { if($x==$l) { $x= 0; } $char.=substr($key,$x, 1); $x++; } for($i= 0;$i<$len;$i++) { if(Ord(substr($data,$i, 1)) <Ord(substr($char,$i, 1))) { $str.=CHR((Ord(substr($data,$i, 1)) + 256)-Ord(substr($char,$i, 1))); } Else { $str.=CHR(Ord(substr($data,$i, 1))-Ord(substr($char,$i, 1))); } } return $str; }}/*$data = ' PHP encryption and decryption algorithm '; Encrypted information $key = ' 123 '; Key $encrypt = Encrypt ($data, $key); $decrypt = Decrypt ($encrypt, $key); Echo $encrypt, "n", $decrypt;*/?>
PHP Cryptographic Decryption class