UNPKG

1.11 kBJavaScriptView Raw
1;(function (root, factory, undef) {
2 if (typeof exports === "object") {
3 // CommonJS
4 module.exports = exports = factory(require("./core"), require("./cipher-core"));
5 }
6 else if (typeof define === "function" && define.amd) {
7 // AMD
8 define(["./core", "./cipher-core"], factory);
9 }
10 else {
11 // Global (browser)
12 factory(root.CryptoJS);
13 }
14}(this, function (CryptoJS) {
15
16 /**
17 * Zero padding strategy.
18 */
19 CryptoJS.pad.ZeroPadding = {
20 pad: function (data, blockSize) {
21 // Shortcut
22 var blockSizeBytes = blockSize * 4;
23
24 // Pad
25 data.clamp();
26 data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
27 },
28
29 unpad: function (data) {
30 // Shortcut
31 var dataWords = data.words;
32
33 // Unpad
34 var i = data.sigBytes - 1;
35 for (var i = data.sigBytes - 1; i >= 0; i--) {
36 if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
37 data.sigBytes = i + 1;
38 break;
39 }
40 }
41 }
42 };
43
44
45 return CryptoJS.pad.ZeroPadding;
46
47}));
\No newline at end of file