niklaslu / php-rsa
php rsa加密解密
Installs: 111
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 2
Open Issues: 0
Type:php
This package is not auto-updated.
Last update: 2025-02-26 16:51:15 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>";