承接 webnarmin/cryptor 相关项目开发

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

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

webnarmin/cryptor

Composer 安装命令:

composer require webnarmin/cryptor

包简介

Authenticated encryption helper with versioned payloads and legacy decrypt support.

README 文档

README

webnarmin/cryptor is a small PHP encryption helper.

Version 2.x writes authenticated, versioned AES-256-GCM payloads and keeps read support for legacy 1.x AES-256-CBC payloads to make migrations possible.

Installation

composer require webnarmin/cryptor

Version Contract

  • 1.x wrote legacy AES-256-CBC payloads.
  • 2.x writes cryptor:v2: AES-256-GCM payloads.
  • 2.x can decrypt legacy 1.x payloads.
  • 2.x is a major version because encrypted output format changes.

Security Model

Cryptor is a symmetric encryption helper. The $privateKey and $publicKey names are kept from the 1.x API, but this library does not implement public-key encryption. Both values are used as key material for deriving the encryption key.

Usage

<?php

require 'vendor/autoload.php';

use webnarmin\Cryptor\Cryptor;

$privateKey = 'your_private_key';
$publicKey = 'your_public_key';
$data = 'Hello, world!';

$cryptor = new Cryptor($privateKey);
$encryptedData = $cryptor->encrypt($data, $publicKey);
$decryptedData = $cryptor->decrypt($encryptedData, $publicKey);

decrypt() preserves the 1.x soft-failure behavior and returns an empty string when decryption fails.

For strict failure handling, use decryptOrFail():

try {
    $decryptedData = $cryptor->decryptOrFail($encryptedData, $publicKey);
} catch (\webnarmin\Cryptor\Exception\CryptorException $exception) {
    // Invalid payload, wrong key, tampered ciphertext, or OpenSSL failure.
}

Running Tests

composer check

License

This library is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固