nawawi/base64-encryption 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

nawawi/base64-encryption

最新稳定版本:v1.0.2

Composer 安装命令:

composer require nawawi/base64-encryption

包简介

A two-way encryption based on MIME base64.

README 文档

README

The Base64Encryption class provides a simple two-way encryption based on MIME base64.

Installation

composer require nawawi/base64-encryption

Example

<?php
if ( file_exists(__DIR__.'/vendor/autoload.php') ) {
    require_once __DIR__.'/vendor/autoload.php';
}

use Nawawi\Utils\Base64Encryption;

// With default key
$encryption = new Base64Encryption();
$encrypted = $encryption->encrypt('test123');
$decrypted = $encryption->decrypt($encrypted);

echo "\$encrypted = $encrypted\n";
echo "\$decrypted = $decrypted\n";

// Set key on initiation
$encryption = new Base64Encryption('encryption_key');
$encrypted = $encryption->encrypt('test123');
$decrypted = $encryption->decrypt($encrypted);

echo "\$encrypted = $encrypted\n";
echo "\$decrypted = $decrypted\n";

// Set key with set_key method
$encryption = new Base64Encryption();
$encryption->set_key('encryption_key');
$encrypted = $encryption->encrypt('test123');
$decrypted = $encryption->decrypt($encrypted);

echo "\$encrypted = $encrypted\n";
echo "\$decrypted = $decrypted\n";

// Set key on call
$encryption = new Base64Encryption();
$encrypted = $encryption->encrypt('test123', 'encryption_key');
$decrypted = $encryption->decrypt($encrypted, 'encryption_key');

echo "\$encrypted = $encrypted\n";
echo "\$decrypted = $decrypted\n";

Encryption key

You may set the encryption key using env variables or constants.

# env
BASE64_ENCRYPTION_KEY = "encryption_key"
// Constant
define('BASE64_ENCRYPTION_KEY', 'encryption_key');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-10