Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
pkcs7-padding
Advanced tools
A tiny package that handles PKCS #7 padding for both strings and byte arrays
A tiny package that handles PKCS #7 padding for both strings and byte arrays.
See RFC 5652, section 6.3 for more details.
var pkcs7 = require('pkcs7-padding');
// padding
var data = new Uint8Array(14);
var padded = pkcs7.pad(data);
// unpadding
var raw = pkcs7.unpad(padded);
Note that unpad()
throws an error when the padded data is incorrect :
try {
var raw = pkcs7.unpad(data);
// use raw data
} catch (e) {
console.error('this is not a valid PKCS #7 padded buffer');
}
It works with strings as well :
var pkcs7 = require('pkcs7-padding');
var padded = pkcs7.pad('this is a text');
var raw = pkcs7.unpad(padded);
You have the ability to change the block size of the padded data.
The default block size is set to 16 bytes.
The maximum block size if 255 bytes.
var pkcs7 = require('pkcs7-padding');
var data = new Uint8Array(14);
var padded = pkcs7.pad('this is a text', 32); // pad data on 32 bytes block size.
console.log(padded.byteLength); // 32
var raw = pkcs7.unpad(padded); // you can unpad any block size
console.log(raw.byteLength); // 14
FAQs
A tiny package that handles PKCS #7 padding for both strings and byte arrays
The npm package pkcs7-padding receives a total of 3,068 weekly downloads. As such, pkcs7-padding popularity was classified as popular.
We found that pkcs7-padding demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.