PHPackages                             random\_tool/random\_encrypt - 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. random\_tool/random\_encrypt

ActiveLibrary[Security](/categories/security)

random\_tool/random\_encrypt
============================

encrypt basic openssl

v1.0.1(3y ago)011Apache-2.0PHPPHP ^7.4 || ^8.0

Since Mar 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/siburuxue/php_random_encrypt)[ Packagist](https://packagist.org/packages/random_tool/random_encrypt)[ RSS](/packages/random-tool-random-encrypt/feed)WikiDiscussions main Synced 1mo ago

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

random\_encrypt
===============

[](#random_encrypt)

基于openssl加密
-----------

[](#基于openssl加密)

### 仅使用了 AES-128-CBC

[](#仅使用了-aes-128-cbc)

#### 根据时间戳所在的时间区间，时区信息计算加密的key，iv

[](#根据时间戳所在的时间区间时区信息计算加密的keyiv)

#### 为每个key设置有效时间(默认5秒，冗余2秒)，在不同的时间区间（左包右闭），相同文本加密后的字符串不同

[](#为每个key设置有效时间默认5秒冗余2秒在不同的时间区间左包右闭相同文本加密后的字符串不同)

#### 默认时区为东八区，加密端和解密端通过统一时区对齐时间，避免不同时区，同时间段，加密后的密文不同，导致无法解密

[](#默认时区为东八区加密端和解密端通过统一时区对齐时间避免不同时区同时间段加密后的密文不同导致无法解密)

#### 在使用时，必须自定义盐值，不能为空。`if ($this->salt === "") { throw new Exception("the salt can not be empty."); }`

[](#在使用时必须自定义盐值不能为空if-this-salt----throw-new-exceptionthe-salt-can-not-be-empty-)

#### Encrypt函数返回 (加密后字符串,key,iv,加密时使用的时间戳) 供解密失败后备查。

[](#encrypt函数返回-加密后字符串keyiv加密时使用的时间戳-供解密失败后备查)

Install
-------

[](#install)

```
composer require random_tool/random_encrypt
```

示例代码：

```
// 依赖注入
use RandomTool\RandomEncrypt;

public function index(RandomEncrypt $encrypt){
    $encrypt->config(['salt' => "salt"]);
    $rs = $encrypt->encrypt("hello world");
    var_dump($rs);
    $s = $encrypt->decrypt($rs[0]);
    var_dump($s);
}
// 静态实例化
use RandomTool\RandomEncrypt;

public function index(){
    $encrypt = RandomEncrypt::init(['salt' => 'salt']);
    $rs = $encrypt->encrypt("hello world");
    var_dump($rs);
    $s = $encrypt->decrypt($rs[0]);
    var_dump($s);
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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 ~0 days

Total

2

Last Release

1165d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7badb2786f4084d248bf806669ad60ac36c8fdc796431420d973e15742c8fc76?d=identicon)[siburuxue](/maintainers/siburuxue)

---

Top Contributors

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

---

Tags

encryptopenssltimestampunrepeat

### Embed Badge

![Health badge](/badges/random-tool-random-encrypt/health.svg)

```
[![Health](https://phpackages.com/badges/random-tool-random-encrypt/health.svg)](https://phpackages.com/packages/random-tool-random-encrypt)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

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

Encryption, decryption, and hashing tools for PHP projects

3171.5k2](/packages/miladrahimi-phpcrypt)[hemiframe/php-aes

PHP class for encrypt and decrypt data with AES algorithm

1030.3k](/packages/hemiframe-php-aes)[mpyw/easycrypt

A class that provides simple interface for decryptable encryption.

234.7k](/packages/mpyw-easycrypt)[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)
