1.0.6 • Published 7 years ago

wheel-aes v1.0.6

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

##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

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago