时间:2021-07-01 10:21:17 帮助过:39人阅读
$mailcont = "邮件正文………超过1024字节………邮件正文"; $crtpath = "/usr/nc-home/webpost/mailbox/d00/1/y/u/yushuai.niu/.user/certkey/wxd.crt"; exec("chmod 777 {$crtpath}"); $fp = fopen($crtpath, "r"); $crt = fread($fp, 8192); fclose($fp); $pubKey = openssl_get_publickey($crt); //从证书中解析公钥 $keyData = openssl_pkey_get_details($pubKey); $blocks = str_split($mailcont, 1000); foreach ($blocks as $block) { //公钥加密 if (!openssl_public_encrypt($block, $chrtext, $keyData['key'])) { echo "
" . openssl_error_string() . "
"; } $chrtext .= $chrtext; } echo "chrtext-->>>$chrtext
"; $keypath = "/usr/nc-home/webpost/mailbox/d00/1/y/u/yushuai.niu/.user/secretkey/wxd.key"; exec("chmod 777 {$keypath}"); $fp = fopen($keypath, "r"); $key = fread($fp, 8192); fclose($fp); $cipher = openssl_pkey_get_private($key); openssl_private_decrypt($chrtext, $dcyCont, $cipher); echo "dcyCont-->>>$dcyCont
";