定制 ageid/encryption-helper 二次开发

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

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

ageid/encryption-helper

最新稳定版本:2.1

Composer 安装命令:

composer create-project ageid/encryption-helper

包简介

AgeID symmetric encryption helper

README 文档

README

AES256 encryption and decryption helper for AgeID using an embedded random salt key.

The implementation is based on Laravel Encrypter.

Requirements: PHP 7

For PHP 5.6 compatibility, please install the PHP 5.x polyfill for random_bytes() :

composer require paragonie/random_compat

Change Log

List of releases and changes, with the latest at the top:

  • v2.1
    • fixed compatibility with php 5.6
    • removed utf8 conversion for salt that was causing entropy loss
  • v2.0 [!] Should be used for v2 endpoint and forward [!]
    • The number of iterations in EncryptionHelper is set by setting the version number on Instantiation; if it not set it will choose the latest version
    • Only allow salt with at least 16 Bytes
    • reduced the number of iterations to be 1024 by default
  • [first-release]

Usage

Installation

Use composer to install the package

composer require ageid/encryption-helper

or download the the package and include the src/* files in your project.

Encryption

By default, it uses a random salt key, but it can be specified in the constructor.

Example:

    use AgeId\EncryptionHelper;


    $password = "8d6ea4d3e6f8c4f8641516baa5e42b85";
    
    $text = "text clear";
    
    $encrypter = new EncryptionHelper($password);
    $encrypted = $encrypter->encrypt($text);

    echo $encrypted;

Decryption

Example:

    use AgeId\EncryptionHelper;

    $password = "8d6ea4d3e6f8c4f8641516baa5e42b85";
    
    
    $hash = "eyJzYWx0IjoiVWluUHJUOFwvZVQ5REZUZ1wvUHo4NyIsImVuY3J5cHRlZCI6IjJxbzgzcmRsMWNWQ0VJTHVjazBJSFE9PSIsIm1hYyI6IjJmYWM3NWY4ZTk4NmI1MGYwMzgwYTcxYTgwMTA3NmNiM2Y3Y2MwYzBkZDNkNWIwOGYxNTI2ZTkwYTRlMTdkZjgifQ==";
    
    $decryptor = new EncryptionHelper($password);
    $decrypted = $decryptor->decrypt($hash);

    echo $decrypted;

Tests

In order to run the tests, please run in the package folder:

composer install
phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2018-05-17