让人难过的 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值