PHP DES加密
public function encrypt($str) { //$str = "hh"; $key = "key:123";//密钥 $cipher = MCRYPT_DES; $models = MCRYPT_MODE_ECB; $iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher,$models),MCRYPT_RAND); //加密 $str_encrypt = mcrypt_encrypt($cipher,$key,$str,$models,$iv); return $str_encrypt; } public function decrypt($str_encrypt) { $key = "key:123";//密钥 $cipher = MCRYPT_DES; $models = MCRYPT_MODE_ECB; $iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher,$models),MCRYPT_RAND); $str_decrpt = mcrypt_decrypt($cipher,$key,$str_encrypt,$models,$iv); return $str_decrpt; }