niklaslu/php-rsa

php rsa加密解密

This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.

Maintainers

Package info

github.com/LCPHP/php-rsa

Type:php

pkg:composer/niklaslu/php-rsa

Statistics

Installs: 116

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

1.0.0 2017-04-20 06:10 UTC

This package is not auto-updated.

Last update: 2026-02-25 21:21:46 UTC


README

php rsa 加密解密类

使用示例 demo.php

<?php

require_once 'vendor/autoload.php';

$Rsa = new \niklaslu\Rsa();

$publicKey = $Rsa->getPublicKeyStr();
echo $publicKey;
echo "<br>";

$pravateKey = $Rsa->getPrivateKeyStr();

echo $pravateKey;
echo "<br>";

$data = 'data1';

// 通过私钥加密
$enc = $Rsa->encryptByPrivate($data);
echo $enc;
echo "<br>";

// 通过公钥解密
$dec = $Rsa->decryptByPublic($enc);
echo $dec;
echo "<br>";


$data = 'data2';

// 通过公钥加密
$enc = $Rsa->encryptByPublic($data);
echo $enc;
echo "<br>";

// 通过私钥解密
$dec = $Rsa->decryptByPrivate($enc);
echo $dec;
echo "<br>";