/*
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
没有合适的资源?快使用搜索试试~ 我知道了~
CryptoJS最新完整版
共88个文件
js:88个
5星 · 超过95%的资源 需积分: 42 733 下载量 177 浏览量
2015-03-19
13:37:32
上传
评论
收藏 154KB ZIP 举报
温馨提示
CryptoJS (crypto.js) 为 JavaScript 提供了各种各样的加密算法。目前已支持的算法包括: MD5 SHA-1 SHA-256 AES Rabbit MARC4 HMAC HMAC-MD5 HMAC-SHA。
资源推荐
资源详情
资源评论
收起资源包目录
CryptoJS v3.1.2.zip (88个子文件)
components
rabbit-legacy-min.js 2KB
core.js 21KB
x64-core.js 8KB
core-min.js 3KB
pad-iso10126.js 846B
sha224-min.js 507B
mode-ofb-min.js 455B
pad-nopadding.js 278B
mode-cfb.js 2KB
hmac.js 4KB
sha1.js 4KB
sha256-min.js 1KB
mode-ctr.js 1KB
format-hex.js 2KB
pbkdf2.js 4KB
sha256.js 5KB
mode-ecb.js 624B
cipher-core-min.js 4KB
pad-iso97971-min.js 340B
md5.js 9KB
sha384.js 2KB
pad-nopadding-min.js 202B
hmac-min.js 760B
ripemd160-min.js 4KB
cipher-core.js 28KB
pad-zeropadding-min.js 340B
mode-ctr-gladman.js 2KB
enc-base64-min.js 869B
pad-iso10126-min.js 366B
mode-ecb-min.js 392B
enc-base64.js 3KB
rabbit.js 6KB
mode-cfb-min.js 639B
enc-utf16-min.js 880B
evpkdf-min.js 654B
sha512.js 13KB
enc-utf16.js 4KB
sha1-min.js 1KB
sha512-min.js 5KB
sha3.js 10KB
evpkdf.js 4KB
pad-iso97971.js 645B
lib-typedarrays.js 2KB
md5-min.js 3KB
rc4.js 3KB
pad-zeropadding.js 749B
mode-ctr-gladman-min.js 820B
lib-typedarrays-min.js 722B
aes.js 8KB
rabbit-legacy.js 6KB
ripemd160.js 9KB
tripledes.js 23KB
tripledes-min.js 10KB
rabbit-min.js 2KB
pad-ansix923-min.js 338B
pad-ansix923.js 994B
x64-core-min.js 640B
sha3-min.js 2KB
rc4-min.js 887B
sha384-min.js 705B
aes-min.js 2KB
mode-ofb.js 1KB
sha224.js 2KB
format-hex-min.js 339B
mode-ctr-min.js 482B
pbkdf2-min.js 752B
rollups
hmac-sha512.js 9KB
hmac-sha384.js 9KB
sha1.js 4KB
pbkdf2.js 5KB
sha256.js 5KB
hmac-sha224.js 5KB
md5.js 6KB
sha384.js 9KB
rabbit.js 13KB
sha512.js 8KB
sha3.js 6KB
hmac-sha256.js 5KB
rc4.js 12KB
aes.js 13KB
rabbit-legacy.js 13KB
ripemd160.js 7KB
tripledes.js 21KB
hmac-ripemd160.js 7KB
hmac-sha3.js 6KB
sha224.js 5KB
hmac-sha1.js 5KB
hmac-md5.js 7KB
共 88 条
- 1
benany307260
- 粉丝: 1
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页