eccrypto-js
Version:
Elliptic curve cryptography library (NodeJS, Browser and Pure JS)
33 lines • 1.13 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
let PADDING = [
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
];
function 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;
}
exports.pad = pad;
function unpad(padded) {
return padded.subarray(0, padded.byteLength - padded[padded.byteLength - 1]);
}
exports.unpad = unpad;
//# sourceMappingURL=index.js.map