微信小程式AES加密解密相關
阿新 • • 發佈:2019-02-18
微信小程式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