PHPackages                             lingyun/think-encryption - 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. lingyun/think-encryption

ActiveThink-extend[Security](/categories/security)

lingyun/think-encryption
========================

The ThinkPHP6 Encryption package.

v1.0.0(2y ago)042Apache-2.0PHP

Since Sep 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ouyanglingyun/think-encryption)[ Packagist](https://packagist.org/packages/lingyun/think-encryption)[ Docs](https://github.com/ouyanglingyun)[ RSS](/packages/lingyun-think-encryption/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Encryption
==========

[](#encryption)

Introduction
------------

[](#introduction)

ThinkPHP's encryption services provide a simple, convenient interface for encrypting and decrypting text via OpenSSL using AES-256 and AES-128 encryption.

Installation
------------

[](#installation)

You may install **think-encryption** via the Composer package manager:

```
composer require lingyun/think-encryption

```

Configuration
-------------

[](#configuration)

Before using ThinkPHP's encrypter, you must set the `key` configuration option in your `config/encrypter.php` configuration file. This configuration value is driven by the `ENCRYPTER.KEY` environment variable. You should use the `php think encrypter:generate` command to generate this variable's value since the `key:generate` command will use PHP's secure random bytes generator to build a cryptographically secure key for your application.

Using The Encrypter
-------------------

[](#using-the-encrypter)

#### Encrypting A Value

[](#encrypting-a-value)

You may encrypt a value using the `encryptString` method provided by the `Crypt` facade. All encrypted values are encrypted using OpenSSL and the AES-256-CBC cipher.Furthermore, all encrypted values are signed with a message authentication code (MAC). The integrated message authentication code will prevent the decryption of any values that have been tampered with by malicious users:

```
use think\facade\Crypt;
use think\encryption\exception\EncryptException;

try {
    $encrypted = Crypt::encryptString($valueToBeEncrypted);
} catch (EncryptException $e) {
    //
}

```

#### Decrypting A Value

[](#decrypting-a-value)

You may decrypt values using the `decryptString` method provided by the `Crypt` facade. If the value can not be properly decrypted, such as when the message authentication code is invalid, an `think\encryption\exception\DecryptException` will be thrown:

```
use think\encryption\exception\DecryptException;
use think\facade\Crypt;

try {
    $decrypted = Crypt::decryptString($encryptedValue);
} catch (DecryptException $e) {
    //
}

```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

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

965d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

encryptionthinkphp encryption

### Embed Badge

![Health badge](/badges/lingyun-think-encryption/health.svg)

```
[![Health](https://phpackages.com/badges/lingyun-think-encryption/health.svg)](https://phpackages.com/packages/lingyun-think-encryption)
```

###  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)[paragonie/ciphersweet

Searchable field-level encryption library for relational databases

4641.2M21](/packages/paragonie-ciphersweet)[ass/xmlsecurity

The XmlSecurity library is written in PHP for working with XML Encryption and Signatures

955.6M30](/packages/ass-xmlsecurity)[pear/crypt_gpg

Provides an object oriented interface to the GNU Privacy Guard (GnuPG). It requires the GnuPG executable to be on the system.

954.4M10](/packages/pear-crypt-gpg)[soved/laravel-gdpr

GDPR compliance with ease

299127.5k2](/packages/soved-laravel-gdpr)

PHPackages © 2026

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