定制 legierski/aes 二次开发

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

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

legierski/aes

最新稳定版本:0.1.0

Composer 安装命令:

composer require legierski/aes

包简介

OpenSSL-compatible AES library

README 文档

README

Perform AES-256 (CBC) encryption/decryption compatible with OpenSSL, CryptoJS, Gibberish AES and possibly other libraries.

Can be used to encrypt data in PHP and decrypt in JavaScript, or vice versa.

Code from here: http://uk3.php.net/manual/en/function.openssl-decrypt.php#107210

Requirements

  • PHP 5.3.3 or later
  • OpenSSL extension for PHP

Installation

In composer.json:

{
    "require": {
        "legierski/aes": "0.1.*"
    }
}

Encrypting data

$aes = new \Legierski\AES\AES;

$encrypted = $aes->encrypt('Very sensitive data', 'password');

// OpenSSL will truncate rows longer than 76 characters, so let's wrap our encrypted data
$encryptedForOpenSSL = $aes->wrapForOpenSSL($encrypted);

Decrypting data

$aes = new \Legierski\AES\AES;

$decrypted = $aes->decrypt('U2FsdGVkX1+nnmEfHgoGQpwSPcT+mDZHxhr8XhEsmIvT2JAxsIzsRocO6x1PErrF', 'password');

Encrypting/decrypting with OpenSSL

$ echo "Very sensitive data" | openssl enc -aes-256-cbc -a -k password

$ echo "U2FsdGVkX1+nnmEfHgoGQpwSPcT+mDZHxhr8XhEsmIvT2JAxsIzsRocO6x1PErrF" | openssl enc -aes-256-cbc -a -d -k password

Encrypting/decrypting with CryptoJS

var encrypted = CryptoJS.AES.encrypt('Very sensitive data', 'password').toString();

var decrypted = CryptoJS.AES.decrypt('U2FsdGVkX1+nnmEfHgoGQpwSPcT+mDZHxhr8XhEsmIvT2JAxsIzsRocO6x1PErrF', 'password').toString(CryptoJS.enc.Utf8);

Encrypting/decrypting with Gibberish AES

var encrypted = GibberishAES.enc('Very sensitive data', 'password');

var decrypted = GibberishAES.dec('U2FsdGVkX1+nnmEfHgoGQpwSPcT+mDZHxhr8XhEsmIvT2JAxsIzsRocO6x1PErrF', 'password');

Testing

Run unit tests:

$ ./vendor/bin/phpunit

Test compliance with PSR2 coding style guide:

$ ./vendor/bin/phpcs --standard=PSR2 ./src

License

The MIT License (MIT)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-06-23