让人难过的 openssl_pkcs7_encrypt
讓人難過的 openssl_pkcs7_encrypt
用PHP.NET的范例,沒有加密結果,也沒有報錯信息,而openssl_pkcs7_sign()函數則返回 error opening input file msg.txt! 反復看了,沒有錯誤,但是為什么會提示沒有打開 msg.txt 文件????????
google了一下,一個帖子中提到在 windows 中只有 絕對路徑才有效,照做了,有了結果。 真的讓人崩潰,浪費了好多時間。
//============================================================//
<?php
//定義郵件頭
$header = array("To" => "",
??? "From" => "HQ <>",
??? "Reply-to" => "",
??? "Subject" => "Eyes only");
//提取證書和需要的文件
$cert = file_get_contents("cacert.pem");
$source = 'D:\www\vhosts\localhost\msg.txt';
$enc='D:\www\vhosts\localhost\enc.txt';
//加密
openssl_pkcs7_encrypt($source, $enc, $cert, null); // $header 替換 null
echo file_get_contents($enc);
//解密 $cert = file_get_contents("cacert.pem");
$key = file_get_contents("cakey.pem");
$enc='D:\www\vhosts\localhost\enc.txt';
$dec='D:\www\vhosts\localhost\decrypted.txt';
openssl_pkcs7_decrypt($enc, $dec, $cert, array( $key, "mm123456"));
$enc=file_get_contents($enc);
echo $enc;
?>
然后,把 $enc PUT給SOCKET。。
轉載于:https://www.cnblogs.com/yisuo/p/6784045.html
總結
以上是生活随笔為你收集整理的让人难过的 openssl_pkcs7_encrypt的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: .NET中使用Redis总结 —— 1.
- 下一篇: VS2013找不到winres.h的解决