PHPackages                             bestyii/yii2-encrypter - 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. bestyii/yii2-encrypter

ActiveYii2-extension[Security](/categories/security)

bestyii/yii2-encrypter
======================

Encryption data for Yii2

v1.0.0(3y ago)2136BSD-3-ClausePHP

Since Aug 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bestyii/yii2-encrypter)[ Packagist](https://packagist.org/packages/bestyii/yii2-encrypter)[ RSS](/packages/bestyii-yii2-encrypter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

YII2 Encrypter
==============

[](#yii2-encrypter)

兼容 `mcrypt_encrypt`及 `openssl_encrypt`

[![Latest Stable Version](https://camo.githubusercontent.com/f85058434391ec7d249357a77a11b9f6eb4c1de9083fd589c8601a58722653e8/68747470733a2f2f706f7365722e707567782e6f72672f626573747969692f796969322d656e637279707465722f762f737461626c65)](https://packagist.org/packages/bestyii/yii2-encrypter)[![Total Downloads](https://camo.githubusercontent.com/56fd8891fa11ade6e5200277f03972cac0542a9b1014f8415887dd372760546f/68747470733a2f2f706f7365722e707567782e6f72672f626573747969692f796969322d656e637279707465722f646f776e6c6f616473)](https://packagist.org/packages/bestyii/yii2-encrypter)[![License](https://camo.githubusercontent.com/b3a32b7837822c401a736986d3cce12222a8a76db6e012cf4d5a9184e8d6f3fb/68747470733a2f2f706f7365722e707567782e6f72672f626573747969692f796969322d656e637279707465722f6c6963656e7365)](https://packagist.org/packages/bestyii/yii2-encrypter)

安装
--

[](#安装)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist bestyii/yii2-encrypter "*"

```

or add

```
"bestyii/yii2-encrypter": "*"

```

to the require section of your `composer.json` file.

### 配置

[](#配置)

配置文件中加入

```
return [
    //...
    'components' => [
        //...
        'encrypter' => [
            'class' => 'bestyii\encrypter\Encrypter',
            'key' => '32bit string',
            'iv' => '32bit string',
        ],
    ],
];
```

如何使用
----

[](#如何使用)

### 手动

[](#手动)

You can now use the encrypter manually in any part of the application to either encrypt a string

```
\Yii::$app->encrypter->encrypt('string to encrypt');
```

or decrypt and encrypted string

```
\Yii::$app->encrypter->decrypt('string to decrypt');
```

### 使用Behavior自动加密/解密

[](#使用behavior自动加密解密)

The extension also comes with a behavior that you can easily attach to any ActiveRecord Model.

Use the following syntax to attach the behavior.

```
public function behaviors()
{
    return [
        'encryption' => [
            'class' => '\bestyii\encrypter\EncrypterBehavior',
            'attributes' => [
                'attributeName',
                'otherAttributeName',
            ],
        ],
    ];
}
```

The behavior will automatically encrypt all the data before saving it on the database and decrypt it after the retrieve.

Keep in mind that the behavior will use the current configuration of the extension for the encryption.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

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

Unknown

Total

1

Last Release

1362d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

securityencryptdecryptyii2extensionencrypterbestyii.comopenssl\_encrypt

### Embed Badge

![Health badge](/badges/bestyii-yii2-encrypter/health.svg)

```
[![Health](https://phpackages.com/badges/bestyii-yii2-encrypter/health.svg)](https://phpackages.com/packages/bestyii-yii2-encrypter)
```

###  Alternatives

[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)[xxtea/xxtea

XXTEA is a fast and secure encryption algorithm. This is a XXTEA library for PHP.

11341.7k](/packages/xxtea-xxtea)[nickcv/yii2-encrypter

Openssl Encrypter for Yii2

19640.0k1](/packages/nickcv-yii2-encrypter)[hyperia/yii2-secure-headers

Secure headers for your Yii2 app

21189.5k](/packages/hyperia-yii2-secure-headers)

PHPackages © 2026

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