• 公钥加密 openssl_public_encrypt(): key parameter is not a valid public key


    公钥加密处理报错, openssl_public_encrypt(): key parameter is not a valid public key

    1.开启open_ssl扩展

    2.转化再加密

    下载的公钥形式类似  '-----BEGIN PUBLIC KEY----- MIGTDVGHWDFNADCBiQKBgQ99XZ6WiHxh94IAKTgSOEev 6tASj3XKVnssChGIZaSvdRXiJshGaR1LNeDbWSDFWE8OjA9sPlwgLJabnP WR283fGu7nRm9/sc4HKRETEF2bj7rcMeEAQAB -----END PUBLIC KEY-----'

    去掉 /

    $str = str_replace(array(" ", " ", " "), "", $str);

    $this->public_key = 'MIGTDVGHWDFNADCBiQKBgQ99XZ6WiHxh94IAKTgSOEev6tASj3XKVnssChGIZaSvdRXiJshGaR1LNeDbWSDFWE8OjA9sPlwgLJabnPWR283fGu7nRm9sc4HKRETEF2bj7rcMeEAQAB';

    再重新拼接  "-----BEGIN PUBLIC KEY----- " . wordwrap($this->public_key, 64, " ", true) . " -----END PUBLIC KEY-----"用来加密

  • 相关阅读:
    libmysql.lib 和 mysqlclient.lib的区别
    输入框禁止输入法
    html加后退按钮
    spry
    migration
    Ruby char <=> ASCII
    Javascript innerhtml
    My SQL 索引
    datepicker
    ruby 常用正则表达式
  • 原文地址:https://www.cnblogs.com/qiuphp/p/13603337.html
Copyright © 2020-2023  润新知