承接 bayfrontmedia/encryptor 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bayfrontmedia/encryptor

Composer 安装命令:

composer require bayfrontmedia/encryptor

包简介

A fast, simple two-way encryption library utilizing OpenSSL.

README 文档

README

A fast, simple two-way encryption library utilizing OpenSSL.

License

This project is open source and available under the MIT License.

Author

Bayfront Media

Requirements

  • PHP ^8.0 (Tested up to 8.4)
  • OpenSSL PHP extension
  • JSON PHP extension

Installation

composer require bayfrontmedia/encryptor

Usage

Start using Encryptor

A private, reproducible key must be passed to the constructor. The same key must be used when encrypting and decrypting. If the key used to encrypt a value is lost, it will not be able to be decrypted.

An optional second constructor parameter allows you to specify which cipher method to use. By default, Encryptor uses AES-256-CBC.

If an invalid cipher method is used, a Bayfront\Encryptor\InvalidCipherException exception will be thrown.

use Bayfront\Encryptor\Encryptor;

$encryptor = new Encryptor('private_key');

Public methods

getKey

Description:

Returns the encryption key.

Parameters:

  • None

Returns:

  • (string)

getCipher

Description:

Returns the cipher method used for encryption.

Parameters:

  • None

Returns:

  • (string)

encrypt

Description:

Encrypts a given value.

Parameters:

  • $value (mixed)
  • $serialize = true (bool)

Returns:

  • (string)

Throws:

  • Bayfront\Encryptor\EncryptException

Example:

try {

    $encrypted = $encryptor->encrypt([
        'name' => 'John',
        'user_id' => 8
    ]);

} catch (EncryptException $e) {
    die($e->getMessage());
}

encryptString

Description:

Encrypts a string without serialization.

Parameters:

  • $value (string)

Returns:

  • (string)

Throws:

  • Bayfront\Encryptor\EncryptException

Example:

try {

    $encrypted_string = $encryptor->encryptString('A string to encrypt');

} catch (EncryptException $e) {
    die($e->getMessage());
}

decrypt

Description:

Decrypts a given value.

Parameters:

  • $data (string)
  • $unserialize = true (bool)

Returns:

  • (mixed)

Throws:

  • Bayfront\Encryptor\DecryptException

Example:

try {

    $decrypted = $encryptor->decrypt($encrypted);

} catch (DecryptException $e) {
    die($e->getMessage());
}

decryptString

Description:

Decrypts a string without unserialization.

Parameters:

  • $data (string)

Returns:

  • (string)

Throws:

  • Bayfront\Encryptor\DecryptException

Example:

try {

    $decrypted_string = $encryptor->decryptString($encrypted_string);

} catch (DecryptException $e) {
    die($e->getMessage());
}

统计信息

  • 总下载量: 832
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固