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

ActiveLibrary[Security](/categories/security)

webguosai/cryptojs-aes
======================

php aes cbc加解密

v2.0.0(1y ago)110MITPHPPHP &gt;=5.6

Since Nov 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/webguosai/cryptojs-aes)[ Packagist](https://packagist.org/packages/webguosai/cryptojs-aes)[ RSS](/packages/webguosai-cryptojs-aes/feed)WikiDiscussions master Synced 1mo ago

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

cryptojs-aes
============

[](#cryptojs-aes)

[![Latest Stable Version](https://camo.githubusercontent.com/bc7441de6c2c4f7de373298dfbcf2077619b02e776a4acf296da81a77810a533/68747470733a2f2f706f7365722e707567782e6f72672f77656267756f7361692f63727970746f6a732d6165732f762f737461626c65)](https://packagist.org/packages/webguosai/cryptojs-aes)[![Total Downloads](https://camo.githubusercontent.com/999ef3cdc9e18262188382a036b3e1c40b1123afc9303fa8e3e9b5766392df0e/68747470733a2f2f706f7365722e707567782e6f72672f77656267756f7361692f63727970746f6a732d6165732f646f776e6c6f616473)](https://packagist.org/packages/webguosai/cryptojs-aes)[![Latest Unstable Version](https://camo.githubusercontent.com/ec8e70ff104cbfa034abefff75d2c10f90f22a1e7f262af55405a8f6fc90487f/68747470733a2f2f706f7365722e707567782e6f72672f77656267756f7361692f63727970746f6a732d6165732f762f756e737461626c65)](https://packagist.org/packages/webguosai/cryptojs-aes)[![License](https://camo.githubusercontent.com/d5a7855c3fcb63cdbe1dac0985b599a2a3722b1755f8df953f17a0635add2837/68747470733a2f2f706f7365722e707567782e6f72672f77656267756f7361692f63727970746f6a732d6165732f6c6963656e7365)](https://packagist.org/packages/webguosai/cryptojs-aes)

运行环境
----

[](#运行环境)

- php &gt;= 5.6
- composer

安装
--

[](#安装)

```
$ composer require webguosai/cryptojs-aes
```

在php中使用
-------

[](#在php中使用)

```
use \Webguosai\Aes;

$array = [
    'name1' => '123',
    'name2' => '456'
];
$key   = 'key4567890123456';
$iv    = 'iv34567890123456';

//加密
$encode = Aes::encrypt($array, $key, $iv); // dc530b22204d3ee7ce729062600fb5c389c43ededed5e5c12d22b82a791fc15e

//解密
$data   = Aes::decrypt($encode, $key, $iv); // ['name1' => '123', 'name2' => '456']
```

在JS中使用
------

[](#在js中使用)

> npm install crypto-js

- crypto-js@4.2.0

```

const key = 'key4567890123456'
const iv = 'iv34567890123456'
const keySize = 128

// 填充key,对照(128=16位,192=24位,256=32位)
const padKey = key.padEnd(keySize / 8, '\0')

// 填充iv(固定16位)
const padIv = iv.padEnd(16, '\0')

// 加密
function encrypt(data) {
    data = JSON.stringify(data)
    const encrypt = CryptoJS.AES.encrypt(data, CryptoJS.enc.Utf8.parse(padKey), {
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7,
        iv: CryptoJS.enc.Utf8.parse(padIv)
    })

    return encrypt.ciphertext.toString(CryptoJS.enc.Hex);
}
// 解密
function decrypt(encrypt) {
    encrypt = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Hex.parse(encrypt));

    const decrypted = CryptoJS.AES.decrypt(encrypt, CryptoJS.enc.Utf8.parse(padKey), {
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7,
        iv: CryptoJS.enc.Utf8.parse(padIv)
    })

    return JSON.parse(decrypted.toString(CryptoJS.enc.Utf8))
}

```

打赏
--

[](#打赏)

 [![](https://camo.githubusercontent.com/49674a436947352122e2d23e49c3324b8dd4a413b414e45849def0667483cbef/68747470733a2f2f7778342e73696e61696d672e636e2f6d77313032342f303038766f44783367793168366c31617a707779736a333075303134777439682e6a7067)](https://camo.githubusercontent.com/49674a436947352122e2d23e49c3324b8dd4a413b414e45849def0667483cbef/68747470733a2f2f7778342e73696e61696d672e636e2f6d77313032342f303038766f44783367793168366c31617a707779736a333075303134777439682e6a7067) [![](https://camo.githubusercontent.com/04e0e05cdd7e51a95a1c2a13838d166ccdb6244a36b9db51b29d7e0c8f75539a/68747470733a2f2f7778322e73696e61696d672e636e2f6d77313032342f303038766f44783367793168366c31617a703576686a3330753031616f6164632e6a7067)](https://camo.githubusercontent.com/04e0e05cdd7e51a95a1c2a13838d166ccdb6244a36b9db51b29d7e0c8f75539a/68747470733a2f2f7778322e73696e61696d672e636e2f6d77313032342f303038766f44783367793168366c31617a703576686a3330753031616f6164632e6a7067)

License
-------

[](#license)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Every ~515 days

Total

3

Last Release

621d ago

Major Versions

v1.0.1 → v2.0.02024-08-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/79b27387fc59b6ba29854bad71e11e6f7269534da234243353c5ec876bf9af5a?d=identicon)[json.](/maintainers/json.)

---

Top Contributors

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

---

Tags

aescbccryptocrypto-jscryptojscryptoaesCBCcrypto-jsCryptoJS

### Embed Badge

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

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

###  Alternatives

[phpseclib/phpseclib

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

5.6k434.8M1.3k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[spomky-labs/aes-key-wrap

AES Key Wrap for PHP.

5022.7M14](/packages/spomky-labs-aes-key-wrap)[poly-crypto/poly-crypto

High-level cryptographic functions that are interoperable between NodeJS and PHP 7.1+

127.8k1](/packages/poly-crypto-poly-crypto)

PHPackages © 2026

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