在PHP中使用RSA加密和解密文本 [英] Encrypt and Decrypt text with RSA in PHP

查看:101
本文介绍了在PHP中使用RSA加密和解密文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有PHP 5.3的任何类提供RSA加密/解密而无需填充?

Is there any class for PHP 5.3 that provides RSA encryption/decryption without padding?

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

I've got private and public key, p,q, and modulus.

推荐答案

您可以使用 phpseclib,这是纯PHP RSA实现:

<?php
include('Crypt/RSA.php');

$privatekey = file_get_contents('private.key');

$rsa = new Crypt_RSA();
$rsa->loadKey($privatekey);

$plaintext = new Math_BigInteger('aaaaaa');
echo $rsa->_exponentiate($plaintext)->toBytes();
?>

这篇关于在PHP中使用RSA加密和解密文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆