wheel-aes

1.0.6 • Public • Published

##Aes latest update at 2016-10-18 author Able ####Des 基于CryptoJs的加密类,可与php互通,目前cbc模式已经测试,其他模式还需验证 ####Usage

import Aes from 'wheel-aes';
let aesObj = new Aes();
let encryptedStr = aesObj.encrypt('hello');
// Z2Vb9yVY+6CrqK+buognmg==
let decryptedStr = aesObj.decrypt(encryptedStr);
// hello
class Aes
{

    private $key = 'keymustbe16bites';
    protected $mode = 'cbc';
    private $cipher = MCRYPT_RIJNDAEL_128;
    private $iv = 'keymustbe16bites.';

    public function __construct()
    {
    }

    public function encrypt($value)
    {
        $str = mcrypt_encrypt($this->cipher, $this->key, $value, $this->mode, $this->iv);
        return base64_encode($str);
    }

    public function decrypt($value)
    {
        $str = base64_decode($value);
        return mcrypt_decrypt($this->cipher, $this->key, $str, $this->mode, $this->iv);
    }
}

Latest Update: 修正加密后出现+时在提交服务器时变成空格的问题 At 2016-12-01 By Able

Readme

Keywords

Package Sidebar

Install

npm i wheel-aes

Weekly Downloads

0

Version

1.0.6

License

ISC

Last publish

Collaborators

  • able.chy