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; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。