PHPackages                             soliphp/aes - 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. soliphp/aes

ActiveLibrary[Security](/categories/security)

soliphp/aes
===========

OpenSSL-compatible AES (128, 192, or 256) CBC library for PHP, based on openssl.

v1.0.0(7y ago)39871MITPHPPHP &gt;=5.5.0

Since Oct 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/soliphp/aes)[ Packagist](https://packagist.org/packages/soliphp/aes)[ Docs](https://github.com/soliphp/aes)[ RSS](/packages/soliphp-aes/feed)WikiDiscussions master Synced 2d ago

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

Soli OpenSSL Aes
----------------

[](#soli-openssl-aes)

基于 OpenSSL 扩展的 AES 加解密库。

- 支持 AES-256-CBC, AES-192-CBC, AES-128-CBC
- 兼容 LibreSSL 2.2+ 命令行
- 兼容 OpenSSL 1.0+ 命令行
- 查看 OpenSSL 版本 `openssl version`

[![Build Status](https://camo.githubusercontent.com/3a1f9f118ccce46114bcee5b04369d693597cb4ce807f3c39cd7a62b246db29f/68747470733a2f2f7472617669732d63692e6f72672f736f6c697068702f6165732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/soliphp/aes)[![Coverage Status](https://camo.githubusercontent.com/2e794079fa37ff9d1f76bd81f249ea53b41f762836d7fc278d62c1e971de0a94/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f736f6c697068702f6165732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/soliphp/aes?branch=master)[![License](https://camo.githubusercontent.com/6e375817677aa37f0728e329b9c21dcdfd0ecf53bc103b1f4a07cb67163a7111/68747470733a2f2f706f7365722e707567782e6f72672f736f6c697068702f6165732f6c6963656e7365)](https://packagist.org/packages/soliphp/aes)

安装
--

[](#安装)

使用 `composer` 进行安装：

```
composer require soliphp/aes

```

使用
--

[](#使用)

```
include __DIR__ . '/vendor/autoload.php';

$aes = new \Soli\Aes();

$data = 'hello world.';
$secret = 'your_secret';

$encrypted = $aes->encrypt($data, $secret);

$decrypted = $aes->decrypt($encrypted, $secret);

var_dump($decrypted);

```

加密数据
----

[](#加密数据)

```
$aes = new \Soli\Aes();

$encrypted = $aes->encrypt('hello world.', 'your_secret');

```

解密数据
----

[](#解密数据)

```
$aes = new \Soli\Aes();

$decrypted = $aes->decrypt('U2FsdGVkX1/mgtCqMAn6S9AKVrqjPn8NoJkysV5JPII=', 'your_secret');

```

256/192/128
-----------

[](#256192128)

默认使用 AES-256-CBC

```
$aes = new \Soli\Aes();
// 等同于
$aes = new \Soli\Aes(256);

```

使用 AES-192-CBC

```
$aes = new \Soli\Aes(192);

```

使用 AES-128-CBC

```
$aes = new \Soli\Aes(128);

```

使用 OpenSSL 命令行加解密
-----------------

[](#使用-openssl-命令行加解密)

加密数据：

```
$ echo -n 'hello world.' | openssl aes-256-cbc -md md5 -base64 -pass pass:your_secret
U2FsdGVkX1/mgtCqMAn6S9AKVrqjPn8NoJkysV5JPII=

```

解密数据：

```
$ echo 'U2FsdGVkX1/mgtCqMAn6S9AKVrqjPn8NoJkysV5JPII=' | openssl aes-256-cbc -md md5 -d -base64 -pass pass:your_secret

```

注：如果命令行下加密的数据含有特殊字符，导致无法加密，使用`单引号`包裹，如：

```
$ echo -n 'hello ~!@%^&*()\{}[]/?' | openssl aes-256-cbc -md md5 -base64 -pass pass:'~!@%^&*()\{}[]/?'

```

md5/sha256 信息摘要算法
-----------------

[](#md5sha256-信息摘要算法)

摘自 [OpenSSL sha256 HISTORY](https://www.openssl.org/docs/man1.1.0/apps/sha256.html#HISTORY)

```
The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0 The FIPS-related options were removed in OpenSSL 1.1.0
在 OpenSSL 1.1.0 版本中，默认信息摘要算法从 MD5 更改为 SHA256

```

所以在使用 OpenSSL 命令行加解密数据时务必显示指定 `-md md5` 参数， 以便在 OpenSSL 1.0 和 1.1 版本下执行命令时都可成功加解密。

当前项目目前只支持 md5 方式。

参考
--

[](#参考)

```
https://github.com/chmduquesne/minibackup/blob/master/samples/OpensslAES.java

```

测试
--

[](#测试)

```
$ cd /path/to/soliphp/aes/
$ composer install
$ phpunit

```

MIT License
-----------

[](#mit-license)

MIT Public License

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

2760d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a27fefc1f3d6ee23049e1d5f8e81f34c8ff055a3849524f18bfb56b816f43382?d=identicon)[ueaner](/maintainers/ueaner)

---

Top Contributors

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

---

Tags

aesaes-128-cbcaes-192-cbcaes-256-cbcopensslphpaesopensslaes-256-cbcsoliphpAES-128-CBCaes-192-cbc

### Embed Badge

![Health badge](/badges/soliphp-aes/health.svg)

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k434.8M1.3k](/packages/phpseclib-phpseclib)[mmeyer2k/dcrypt

A petite library of encryption functionality for PHP

98727.2k1](/packages/mmeyer2k-dcrypt)[spomky-labs/aes-key-wrap

AES Key Wrap for PHP.

5022.7M14](/packages/spomky-labs-aes-key-wrap)[spomky-labs/php-aes-gcm

AES GCM (Galois Counter Mode) PHP implementation.

724.9M20](/packages/spomky-labs-php-aes-gcm)[nzo/url-encryptor-bundle

The NzoUrlEncryptorBundle is a Symfony Bundle used to Encrypt and Decrypt data and variables in the Web application or passed through URL

961.0M2](/packages/nzo-url-encryptor-bundle)

PHPackages © 2026

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