/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
/**
* Cipher core components.
*/
CryptoJS.lib.Cipher || (function (undefined) {
// Shortcuts
var C = CryptoJS;
var C_lib = C.lib;
var Base = C_lib.Base;
var WordArray = C_lib.WordArray;
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
var C_enc = C.enc;
var Utf8 = C_enc.Utf8;
var Base64 = C_enc.Base64;
var C_algo = C.algo;
var EvpKDF = C_algo.EvpKDF;
/**
* Abstract base cipher template.
*
* @property {number} keySize This cipher's key size. Default: 4 (128 bits)
* @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
* @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
* @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
*/
var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
/**
* Configuration options.
*
* @property {WordArray} iv The IV to use for this operation.
*/
cfg: Base.extend(),
/**
* Creates this cipher in encryption mode.
*
* @param {WordArray} key The key.
* @param {Object} cfg (Optional) The configuration options to use for this operation.
*
* @return {Cipher} A cipher instance.
*
* @static
*
* @example
*
* var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
*/
createEncryptor: function (key, cfg) {
return this.create(this._ENC_XFORM_MODE, key, cfg);
},
/**
* Creates this cipher in decryption mode.
*
* @param {WordArray} key The key.
* @param {Object} cfg (Optional) The configuration options to use for this operation.
*
* @return {Cipher} A cipher instance.
*
* @static
*
* @example
*
* var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
*/
createDecryptor: function (key, cfg) {
return this.create(this._DEC_XFORM_MODE, key, cfg);
},
/**
* Initializes a newly created cipher.
*
* @param {number} xformMode Either the encryption or decryption transormation mode constant.
* @param {WordArray} key The key.
* @param {Object} cfg (Optional) The configuration options to use for this operation.
*
* @example
*
* var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
*/
init: function (xformMode, key, cfg) {
// Apply config defaults
this.cfg = this.cfg.extend(cfg);
// Store transform mode and key
this._xformMode = xformMode;
this._key = key;
// Set initial values
this.reset();
},
/**
* Resets this cipher to its initial state.
*
* @example
*
* cipher.reset();
*/
reset: function () {
// Reset data buffer
BufferedBlockAlgorithm.reset.call(this);
// Perform concrete-cipher logic
this._doReset();
},
/**
* Adds data to be encrypted or decrypted.
*
* @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
*
* @return {WordArray} The data after processing.
*
* @example
*
* var encrypted = cipher.process('data');
* var encrypted = cipher.process(wordArray);
*/
process: function (dataUpdate) {
// Append
this._append(dataUpdate);
// Process available blocks
return this._process();
},
/**
* Finalizes the encryption or decryption process.
* Note that the finalize operation is effectively a destructive, read-once operation.
*
* @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
*
* @return {WordArray} The data after final processing.
*
* @example
*
* var encrypted = cipher.finalize();
* var encrypted = cipher.finalize('data');
* var encrypted = cipher.finalize(wordArray);
*/
finalize: function (dataUpdate) {
// Final data update
if (dataUpdate) {
this._append(dataUpdate);
}
// Perform concrete-cipher logic
var finalProcessedData = this._doFinalize();
return finalProcessedData;
},
keySize: 128/32,
ivSize: 128/32,
_ENC_XFORM_MODE: 1,
_DEC_XFORM_MODE: 2,
/**
* Creates shortcut functions to a cipher's object interface.
*
* @param {Cipher} cipher The cipher to create a helper for.
*
* @return {Object} An object with encrypt and decrypt shortcut functions.
*
* @static
*
* @example
*
* var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
*/
_createHelper: (function () {
function selectCipherStrategy(key) {
if (typeof key == 'string') {
return PasswordBasedCipher;
} else {
return SerializableCipher;
}
}
return function (cipher) {
return {
encrypt: function (message, key, cfg) {
return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
},
decrypt: function (ciphertext, key, cfg) {
return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
}
};
};
}())
});
/**
* Abstract base stream cipher template.
*
* @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
*/
var StreamCipher = C_lib.StreamCipher = Cipher.extend({
_doFinalize: function () {
// Process partial blocks
var finalProcessedBlocks = this._process(!!'flush');
return finalProcessedBlocks;
},
blockSize: 1
});
/**
* Mode namespace.
*/
var C_mode = C.mode = {};
/**
* Abstract base block cipher mode template.
*/
var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
/**
* Creates this mode for encryption.
*
* @param {Cipher} cipher A block cipher instance.
* @param {Array} iv The IV words.
*
* @static
*
* @example
*
* var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
*/
createEncryptor: function (cipher, iv) {
return this.Encryptor.create(cipher, iv);
},
/**
* Creates this mode for decryption.
*
* @param {Cipher} cipher A block cipher instance.
* @param {Array} iv The IV words.
*
* @static
*
* @example
*
* var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
*/
createDecryptor: function (cipher, iv) {
return this.Decryptor.create(ciph
没有合适的资源?快使用搜索试试~ 我知道了~
小程序AES加密
共91个文件
js:89个
ds_store:2个
4星 · 超过85%的资源 需积分: 42 61 下载量 111 浏览量
2018-03-28
16:27:38
上传
评论 3
收藏 195KB ZIP 举报
温馨提示
微信小程序的AES加密,下载拖入工程,引用就可以直接使用
资源推荐
资源详情
资源评论
收起资源包目录
utils.zip (91个子文件)
utils
aes_util.js 451B
CryptoJS
components
evpkdf-min.js 654B
evpkdf.js 4KB
x64-core-min.js 640B
rc4-min.js 887B
pad-ansix923-min.js 338B
mode-ctr-min.js 482B
mode-ctr-gladman.js 2KB
pad-iso10126-min.js 366B
lib-typedarrays.js 2KB
x64-core.js 8KB
mode-ctr-gladman-min.js 820B
rabbit-legacy.js 6KB
mode-cfb.js 2KB
cipher-core.js 28KB
sha256-min.js 1KB
mode-ofb.js 1KB
enc-utf16-min.js 880B
mode-ecb.js 624B
mode-cfb-min.js 639B
ripemd160.js 9KB
pad-nopadding-min.js 202B
hmac-min.js 760B
sha3.js 10KB
pad-zeropadding.js 749B
format-hex-min.js 339B
aes-min.js 2KB
rabbit-legacy-min.js 2KB
pbkdf2-min.js 752B
mode-ofb-min.js 455B
rabbit-min.js 2KB
sha384-min.js 705B
md5.js 9KB
tripledes.js 23KB
rabbit.js 6KB
sha3-min.js 2KB
tripledes-min.js 10KB
hmac.js 4KB
core.js 21KB
aes.js 8KB
enc-utf16.js 4KB
ripemd160-min.js 4KB
mode-ctr.js 1KB
pad-zeropadding-min.js 340B
lib-typedarrays-min.js 722B
format-hex.js 2KB
sha1.js 4KB
core-min.js 3KB
pbkdf2.js 4KB
cipher-core-min.js 4KB
mode-ecb-min.js 392B
pad-iso97971.js 645B
pad-iso10126.js 846B
md5-min.js 3KB
pad-iso97971-min.js 340B
enc-base64-min.js 869B
sha384.js 2KB
sha256.js 5KB
sha224-min.js 507B
sha512.js 13KB
sha1-min.js 1KB
rc4.js 3KB
pad-nopadding.js 278B
enc-base64.js 3KB
sha512-min.js 5KB
sha224.js 2KB
pad-ansix923.js 994B
rollups
hmac-ripemd160.js 7KB
hmac-sha3.js 6KB
rabbit-legacy.js 13KB
hmac-sha224.js 5KB
ripemd160.js 7KB
sha3.js 6KB
hmac-sha384.js 9KB
md5.js 6KB
tripledes.js 21KB
rabbit.js 13KB
aes.js 18KB
sha1.js 4KB
pbkdf2.js 5KB
hmac-sha512.js 9KB
sha384.js 9KB
sha256.js 5KB
sha512.js 8KB
rc4.js 12KB
hmac-md5.js 7KB
hmac-sha256.js 5KB
sha224.js 5KB
hmac-sha1.js 5KB
.DS_Store 6KB
.DS_Store 6KB
共 91 条
- 1
资源评论
- Wang丶Yan2018-10-29嗯,还可以不错。
- 沉默理想2019-05-30谢谢分享,学习了。
cooper_木
- 粉丝: 3
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功