We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2ed133b commit 463b182Copy full SHA for 463b182
src/core/crypto.js
@@ -1407,11 +1407,12 @@ class CipherTransform {
1407
// Append some chars equal to "16 - (M mod 16)"
1408
// where M is the string length (see section 7.6.2 in PDF specification)
1409
// to have a final string where the length is a multiple of 16.
1410
+ // Special note:
1411
+ // "Note that the pad is present when M is evenly divisible by 16;
1412
+ // it contains 16 bytes of 0x10."
1413
const strLen = s.length;
1414
const pad = 16 - (strLen % 16);
- if (pad !== 16) {
- s = s.padEnd(16 * Math.ceil(strLen / 16), String.fromCharCode(pad));
- }
1415
+ s += String.fromCharCode(pad).repeat(pad);
1416
1417
// Generate an initialization vector
1418
const iv = new Uint8Array(16);
0 commit comments