PHPackages                             swordying/crypter - 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. [Security](/categories/security)
4. /
5. swordying/crypter

ActiveLibrary[Security](/categories/security)

swordying/crypter
=================

字符串非对称加密解密

1.0.0(2y ago)05MITPHP

Since Oct 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Swordying/crypter)[ Packagist](https://packagist.org/packages/swordying/crypter)[ RSS](/packages/swordying-crypter/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

RSA 加密解密
========

[](#rsa-加密解密)

1、解决需求
------

[](#1解决需求)

- 当诸如 身份证号、银行卡号 直接存入数据库就有泄漏的风险，所以需要非对称加密后存储。但非对成加密后的密文无法用于数据库查询，所以需要在数据表中增加两个字段，1密文字段、2散列字段，从而达到字符串非对成加密后，依然可以进行数据库查询。

2、composer 安装
-------------

[](#2composer-安装)

- `$ composer require swordying/crypter`

### 1. 加密解密

[](#1-加密解密)

```
// 引入类文件
require __DIR__.'/vendor/autoload.php';

# 实例化
$crypter = new \Swordying\Crypter();

# 明文
$ho = 'Hello World!';

# 加密后的值
$en = $crypter -> handle($ho);

# 散列值
$md = $crypter -> md($ho);

# 解密后的值
$de = $crypter -> de($en['en']);

var_export($ho);
echo "\n";
var_export($en);
echo "\n";
var_export($md);
echo "\n";
var_export($de);
```

### 2. 生成公钥私钥

[](#2-生成公钥私钥)

```
$keys = \Swordying\Crypter::createKeys();
var_export($keys);
// [
//     'public_key' => '',
//     'private_key' => '',
// ];
```

3、备注
----

[](#3备注)

1. 散列盐为：`$=$.salt.$=$`
2. 公钥文件：`./src/public.key`
3. 密钥文件：`./src/private.key`

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

976d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b489d15c5d1e3850595867542f0105337e83831420b36594469b349128ab342?d=identicon)[Swordying](/maintainers/Swordying)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/swordying-crypter/health.svg)

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

###  Alternatives

[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k18.0M134](/packages/mews-purifier)[paragonie/ecc

PHP Elliptic Curve Cryptography library

24772.0k35](/packages/paragonie-ecc)

PHPackages © 2026

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