定制 fixer112/encrypter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

fixer112/encrypter

最新稳定版本:v1.2.0

Composer 安装命令:

composer require fixer112/encrypter

包简介

Simple AES-256-CBC encrypter decrypter

README 文档

README

Simple AES-256-CBC encryption/decryption PHP library using fixed key and IV loaded from environment variables.

Installation

Install via Composer:

composer require fixer112/encrypter

Environment Setup

Create a .env file in your project root with these variables:

ENCRYPTER_KEY=your-secret-key-here
ENCRYPTER_IV=your-iv-here

Usage

<?php

require 'vendor/autoload.php';

use Fixer112\Encrypter\Encrypter;



try {
    // Load .env (if not using Laravel, you need to load it manually)
    $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
    $dotenv->load();

    $encrypter = new Encrypter();

    //or initiate key and iv

    //$key = $iv = "password";
    //$encrypter = new Encrypter($key,$iv);

    $plaintext = "Hello, world!";
    $encrypted = $encrypter->encrypt($plaintext);
    echo "Encrypted: " . $encrypted . PHP_EOL;

    $decrypted = $encrypter->decrypt($encrypted);
    echo "Decrypted: " . $decrypted . PHP_EOL;

} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

Notes

  • This package depends on your .env file to provide ENCRYPTER_KEY and ENCRYPTER_IV.

  • Make sure to keep your key and IV secret and do not commit them to public repositories.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-03