PHPackages                             tanren1234/rsa - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tanren1234/rsa

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tanren1234/rsa
==============

A rsa SDK.

286PHP

Since Nov 17Pushed 5y agoCompare

[ Source](https://github.com/tanren1234/rsa)[ Packagist](https://packagist.org/packages/tanren1234/rsa)[ RSS](/packages/tanren1234-rsa/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

 tanren1234/rsa
================

[](#-tanren1234rsa-)

 rsa数据加解密，生成签名，验证签名

Installing
----------

[](#installing)

```
$ composer require tanren1234/rsa:dev-master -vvv
```

Usage
-----

[](#usage)

#### 生成公私钥

[](#生成公私钥)

- 如果报下面的错就需要设置config路径

> Warning: openssl\_pkey\_export(): cannot get key from parameter 1

```
require __DIR__ .'/vendor/autoload.php';
use Rsa\GenerateSecretKey;
$client = new GenerateSecretKey();
$client->setOpensslPath('D:\phpstudy_pro\Extensions\php\php7.3.4nts\extras\ssl\openssl.cnf');
var_dump($client->generate());
```

#### 数据加解密

[](#数据加解密)

```
require __DIR__ .'/vendor/autoload.php';
use Rsa\RsaClient;

// 生成的私钥
$privatePEMKey="xxxxx";

// 生成的公钥
$publicPEMKey = "xxxxx";

// 需要加密的字符串
$str ="213232";

$rsa = new RsaClient();
$rsa->rsaPublicKey =$publicPEMKey;
$rsa->rsaPrivateKey = $privatePEMKey;
$encrypted = $rsa->publicEncryptRsa($str);
var_dump($encrypted); // 加密数据
$decrypted = $rsa->privateDecryptRsa($encrypted);
var_dump($decrypted); // 解密后的数据
```

#### 备注

[](#备注)

> 加解密均采用分段的方式，数据量过大必须使用分段

- 生成公私钥的字节为2048 要加密的最大字符数（字节）=2048/8-11（使用填充时）=245个字符
- 生成公私钥的字节为2048 要解密的最大字符数（字节）=2048/8（使用填充时）=256个字符

### 新增java版解密 java目录

[](#新增java版解密-java目录)

### golang版加解密 go目录

[](#golang版加解密-go目录)

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/tanren1234/rsa/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/tanren1234/rsa/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13973355?v=4)[tanren1234](/maintainers/tanren1234)[@tanren1234](https://github.com/tanren1234)

---

Top Contributors

[![tanren1234](https://avatars.githubusercontent.com/u/13973355?v=4)](https://github.com/tanren1234 "tanren1234 (5 commits)")

---

Tags

issue-trackerphprsa

### Embed Badge

![Health badge](/badges/tanren1234-rsa/health.svg)

```
[![Health](https://phpackages.com/badges/tanren1234-rsa/health.svg)](https://phpackages.com/packages/tanren1234-rsa)
```

###  Alternatives

[phpseclib/bcmath_compat

PHP 5.x-8.x polyfill for bcmath extension

16821.5M26](/packages/phpseclib-bcmath-compat)[wikimedia/aho-corasick

An implementation of the Aho-Corasick string matching algorithm.

584.0M7](/packages/wikimedia-aho-corasick)[tecnickcom/tc-lib-color

PHP library to manipulate various color representations

247.9M25](/packages/tecnickcom-tc-lib-color)[jfcherng/php-mb-string

A high performance multibytes sting implementation for frequently reading/writing operations.

145.8M3](/packages/jfcherng-php-mb-string)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
