相关疑难解决方法(0)

使用PHP中的RSA加密和解密文本

是否有任何PHP 5.3的类,它将使用RSA提供文本加密/解密而无需填充?

我有私钥和公钥,p,q和模数.

php rsa

36
推荐指数
3
解决办法
11万
查看次数

AES 在 PHP 中使用 OpenSSL 加密/在 Node.js 中解密

我正在使用 PHP 和 Nodejs 使用 OpenSSL 进行对称加密。PHP 使用 OpenSSL 库,Node.js 解密基于实现的加密。问题是 Node.js 中解密的文本只是部分正确

用于加密的 PHP 函数

function encrypt($text, $pw, $base64 = true) {

    $method = 'aes-256-cbc';
    $iv_len = openssl_cipher_iv_length($method);
    $iv = openssl_random_pseudo_bytes($iv_len);
    
    $pw = substr(md5($pw),0,32);

    $cipher =  openssl_encrypt ($text ,$method ,$pw ,!$base64 ,$iv );

    if($base64) {
            $pw = base64_encode($pw);
            $iv = base64_encode($iv);
        }

    return array(
        'iv' => $iv,
        'pw' => $pw,
        'text' => $text,
        'cipher' => $cipher
    );
}
Run Code Online (Sandbox Code Playgroud)

nodejs中的解密

var cipher = new Buffer(data.cipher, 'base64');
var iv …
Run Code Online (Sandbox Code Playgroud)

php node.js php-openssl

5
推荐指数
1
解决办法
7958
查看次数

标签 统计

php ×2

node.js ×1

php-openssl ×1

rsa ×1