Not clear des algorithm can be seen in Wikipedia
<?PHPclassdesede{/** * Encryption * @param $data encrypted plaintext * @param $key des private key * @param $use 3DES whether 3DES encryption is enabled, not enabled by default*/ functionEncrypt$data= ",$key= ",$use 3DES=False) { if(Empty($data) ||Empty($key)) { return False; } $cipher=$use 3DES? Mcrypt_tripledes:Mcrypt_des; $modes=MCRYPT_MODE_ECB; #Add PKCS7 padding. $block= Mcrypt_get_block_size ($cipher,$modes); $pad=$block- (strlen($data) %$block); $data.=str_repeat(CHR($pad),$pad); $iv= Mcrypt_create_iv (Mcrypt_get_iv_size ($cipher,$modes),Mcrypt_rand); $encrypted= @mcrypt_encrypt ($cipher,$key,$data,$modes,$iv); return $encrypted; } /** decryption * @param $data decryption * @param $key des private key * @param $use 3DES whether 3DES encryption is enabled, not enabled by default*/ functionDecrypt$data= ",$key= ",$use 3DES=False) { if(Empty($data) ||Empty($key)) { return False; } $cipher=$use 3DES? Mcrypt_tripledes:Mcrypt_des; $modes=MCRYPT_MODE_ECB; $iv= Mcrypt_create_iv (Mcrypt_get_iv_size ($cipher,$modes),Mcrypt_rand); $data= @mcrypt_decrypt ($cipher,$key,$data,$modes,$iv); #Strip padding out. $block= Mcrypt_get_block_size ($cipher,$modes); $pad=Ord($data[($len=strlen($data))-1]); $decrypted=substr($data, 0,strlen($data) -$pad); return $decrypted; }}