Home > Backend Development > PHP Tutorial > rsa - php openssl 函数不能用?

rsa - php openssl 函数不能用?

WBOY
Release: 2016-06-06 20:15:56
Original
1172 people have browsed it

<code>extension_loaded('openssl') or die('openssl扩展未安装');  

$pukey='-----BEGIN PUBLIC KEY-----
    MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCivkFM06PJ2agLiF3rMyItmXbC
    756SnYzJCPF2sBfUqxi8U/TFY72y5U4EdbgQMF+aP4ldBPUYpCXE7R6oQ96AEx/I
    NCj9MDxGspXONXT4aPEkfNo7od0LzdLTLg+tdJklk7gti8jZg7kmuW3eG367KdEm
    58Q116H+FI1D48kTNwIDAQAB
    -----END PUBLIC KEY-----
    ';
$pikey='-----BEGIN RSA PRIVATE KEY-----
    MIICXgIBAAKBgQCivkFM06PJ2agLiF3rMyItmXbC756SnYzJCPF2sBfUqxi8U/TF
    Y72y5U4EdbgQMF+aP4ldBPUYpCXE7R6oQ96AEx/INCj9MDxGspXONXT4aPEkfNo7
    od0LzdLTLg+tdJklk7gti8jZg7kmuW3eG367KdEm58Q116H+FI1D48kTNwIDAQAB
    AoGBAJFLySMdRPr+n0CEpE1LnrUVcWmC45FEpiAKIwJzHyOZCgGB92OPtBqXDPuA
    Wi/h8EjXdv0cYvJ4Atx5U0ipJ2jGrnBsxOx2pDj5TfrobNlaLlvK0N3Gqrb3l5kW
    XUAJHe9kBReyNaenwkUPnMJ00QHReUUqtxCieM6trEicj9IxAkEAzgage1kFsDSs
    tFxskHiADwKS4zoILMQ6LYY+1k7L+znRcU3k/a+/KiBzUIfOeDg2wcS60tknPqt0
    cS8KWcvtWQJBAMo38psD8rTtg30mdSJpldlcuXQVUuDKnggseszeWKZaumE3H/pL
    3XiT8zkl5UdNJ/N2AdeRRoPisxrJQ48bIw8CQFJy3nheaONaQR8wuZWbU4wuOIBM
    sgbQRIQBbFYxVHpmagXQ6WoIkhUWxW8d2ifMP0WOKEHG+2ieDsxYyeijrokCQQCg
    5ldhRIjvsTS4dcsp8H1NEFx3oyfouQ95TXsAW8KJyxMVmzkUfRzhfkc/J4oBa8Do
    FPNuRKeo9M6x94aL7Xm9AkEApj3ixqfITd8gl1EO+mZb5rUgnW9nR37ExiQSMihO
    pRQh1Igfmm90d+i7KYcTImwj5F5ofZS/Kvb737VRKLlJ6A==
    -----END RSA PRIVATE KEY-----';

var_dump(openssl_pkey_get_private($pikey));
var_dump(openssl_pkey_get_public($pukey));</code>
Copy after login
Copy after login

phpinfo();可看到openssl 扩展已安装
但是所有 openssl_* 函数都返回 false,

回复内容:

<code>extension_loaded('openssl') or die('openssl扩展未安装');  

$pukey='-----BEGIN PUBLIC KEY-----
    MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCivkFM06PJ2agLiF3rMyItmXbC
    756SnYzJCPF2sBfUqxi8U/TFY72y5U4EdbgQMF+aP4ldBPUYpCXE7R6oQ96AEx/I
    NCj9MDxGspXONXT4aPEkfNo7od0LzdLTLg+tdJklk7gti8jZg7kmuW3eG367KdEm
    58Q116H+FI1D48kTNwIDAQAB
    -----END PUBLIC KEY-----
    ';
$pikey='-----BEGIN RSA PRIVATE KEY-----
    MIICXgIBAAKBgQCivkFM06PJ2agLiF3rMyItmXbC756SnYzJCPF2sBfUqxi8U/TF
    Y72y5U4EdbgQMF+aP4ldBPUYpCXE7R6oQ96AEx/INCj9MDxGspXONXT4aPEkfNo7
    od0LzdLTLg+tdJklk7gti8jZg7kmuW3eG367KdEm58Q116H+FI1D48kTNwIDAQAB
    AoGBAJFLySMdRPr+n0CEpE1LnrUVcWmC45FEpiAKIwJzHyOZCgGB92OPtBqXDPuA
    Wi/h8EjXdv0cYvJ4Atx5U0ipJ2jGrnBsxOx2pDj5TfrobNlaLlvK0N3Gqrb3l5kW
    XUAJHe9kBReyNaenwkUPnMJ00QHReUUqtxCieM6trEicj9IxAkEAzgage1kFsDSs
    tFxskHiADwKS4zoILMQ6LYY+1k7L+znRcU3k/a+/KiBzUIfOeDg2wcS60tknPqt0
    cS8KWcvtWQJBAMo38psD8rTtg30mdSJpldlcuXQVUuDKnggseszeWKZaumE3H/pL
    3XiT8zkl5UdNJ/N2AdeRRoPisxrJQ48bIw8CQFJy3nheaONaQR8wuZWbU4wuOIBM
    sgbQRIQBbFYxVHpmagXQ6WoIkhUWxW8d2ifMP0WOKEHG+2ieDsxYyeijrokCQQCg
    5ldhRIjvsTS4dcsp8H1NEFx3oyfouQ95TXsAW8KJyxMVmzkUfRzhfkc/J4oBa8Do
    FPNuRKeo9M6x94aL7Xm9AkEApj3ixqfITd8gl1EO+mZb5rUgnW9nR37ExiQSMihO
    pRQh1Igfmm90d+i7KYcTImwj5F5ofZS/Kvb737VRKLlJ6A==
    -----END RSA PRIVATE KEY-----';

var_dump(openssl_pkey_get_private($pikey));
var_dump(openssl_pkey_get_public($pukey));</code>
Copy after login
Copy after login

phpinfo();可看到openssl 扩展已安装
但是所有 openssl_* 函数都返回 false,

用这个命令试试呢

<code>php -m|grep openssl</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template