UNPKG

typed-wx-api

Version:
27 lines 796 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PKCS7Encoder = void 0; /** * 提供基于PKCS7算法的加解密接口 * @internal */ class PKCS7Encoder { static decode(text) { let pad = text[text.length - 1]; if (pad < 1 || pad > 32) { pad = 0; } return text.slice(0, text.length - pad); } static encode(text) { const blockSize = 32; const textLength = text.length; //计算需要填充的位数 const amountToPad = blockSize - (textLength % blockSize); const result = new Buffer(amountToPad); result.fill(amountToPad); return Buffer.concat([text, result]); } } exports.PKCS7Encoder = PKCS7Encoder; //# sourceMappingURL=pkcs7_encode.js.map