You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
2 years ago
|
;(function (root, factory, undef) {
|
||
|
if (typeof exports === "object") {
|
||
|
// CommonJS
|
||
|
module.exports = exports = factory(require("./core"), require("./cipher-core"));
|
||
|
}
|
||
|
else if (typeof define === "function" && define.amd) {
|
||
|
// AMD
|
||
|
define(["./core", "./cipher-core"], factory);
|
||
|
}
|
||
|
else {
|
||
|
// Global (browser)
|
||
|
factory(root.CryptoJS);
|
||
|
}
|
||
|
}(this, function (CryptoJS) {
|
||
|
|
||
|
/**
|
||
|
* Zero padding strategy.
|
||
|
*/
|
||
|
CryptoJS.pad.ZeroPadding = {
|
||
|
pad: function (data, blockSize) {
|
||
|
// Shortcut
|
||
|
var blockSizeBytes = blockSize * 4;
|
||
|
|
||
|
// Pad
|
||
|
data.clamp();
|
||
|
data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
|
||
|
},
|
||
|
|
||
|
unpad: function (data) {
|
||
|
// Shortcut
|
||
|
var dataWords = data.words;
|
||
|
|
||
|
// Unpad
|
||
|
var i = data.sigBytes - 1;
|
||
|
while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
|
||
|
i--;
|
||
|
}
|
||
|
data.sigBytes = i + 1;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
return CryptoJS.pad.ZeroPadding;
|
||
|
|
||
|
}));
|