微信小程序AES加密解密相关

微信小程序AES加密解密:


加密:

Encrypt :function(word){

    var mode = new Crypto.mode.CBC(Crypto.pad.pkcs7);
    var eb = Crypto.charenc.UTF8.stringToBytes(word);
    var kb = Crypto.charenc.UTF8.stringToBytes("1234567812345678");//KEY
    var vb = Crypto.charenc.UTF8.stringToBytes("8765432187654321");//IV
    var ub = Crypto.AES.encrypt(eb,kb,{iv:vb,mode:mode,asBpytes:true});
    return ub;

},

解密:

  Decrypt:function  (word){
    var mode = new Crypto.mode.CBC(Crypto.pad.pkcs7);
    var eb = Crypto.util.base64ToBytes(word);
   var kb = Crypto.charenc.UTF8.stringToBytes("1234567812345678");//KEY
    var vb = Crypto.charenc.UTF8.stringToBytes("8765432187654321");//IV
    var ub = Crypto.AES.decrypt(eb,kb,{asBpytes:true,mode:mode,iv:vb});
    return ub;

},

库调用:

var Crypto = require('../pages/cryptojs/cryptojs').Crypto;


源码下载:

http://download.csdn.net/detail/happy__everyday/9729637

你可能感兴趣的:(微信小程序相关)