@walletconnect/crypto
Version:
Isomorphic Cryptography Library for AES, HMAC and SHA2
34 lines • 1.16 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pkcs7 = void 0;
const PADDING = [
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
];
exports.pkcs7 = {
pad(plaintext) {
const padding = PADDING[plaintext.byteLength % 16 || 0];
const result = new Uint8Array(plaintext.byteLength + padding.length);
result.set(plaintext);
result.set(padding, plaintext.byteLength);
return result;
},
unpad(padded) {
return padded.subarray(0, padded.byteLength - padded[padded.byteLength - 1]);
},
};
//# sourceMappingURL=pkcs7.js.map