Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
The libqp npm package is a library for encoding and decoding quoted-printable data, which is a method used to encode binary data into a text format that can be safely transmitted over text-based protocols such as email.
Encoding
This feature allows you to encode a string into quoted-printable format. The code sample demonstrates how to encode the string 'Hello, World!' using the libqp package.
const libqp = require('libqp');
const input = 'Hello, World!';
const encoded = libqp.encode(input);
console.log(encoded);
Decoding
This feature allows you to decode a quoted-printable encoded string back into its original form. The code sample demonstrates how to decode the string 'Hello=2C=20World=21' using the libqp package.
const libqp = require('libqp');
const encoded = 'Hello=2C=20World=21';
const decoded = libqp.decode(encoded);
console.log(decoded);
The quoted-printable package provides similar functionality for encoding and decoding quoted-printable data. It is a straightforward and easy-to-use library that offers similar performance and ease of use as libqp.
The emailjs-utf7 package is another library that deals with encoding and decoding, but it focuses on UTF-7 encoding, which is used in email systems. While it does not directly handle quoted-printable encoding, it serves a similar purpose in the context of email data encoding.
Encode and decode quoted-printable strings according to RFC2045.
Install with npm
npm install libqp
Require in your script
const libqp = require('libqp');
Encode Buffer objects or unicode strings with
libqp.encode(val) → String
Where
Example
libqp.encode('jõgeva');
// j=C3=B5geva
Quoted-Printable encoded lines are limited to 76 characters but encode
method might return lines longer than the limit.
To enforce soft line breaks on lines longer than 76 (or any other length) characters, use wrap
libqp.wrap(str[, lineLength]) → String
Where
Example
libqp.wrap('abc j=C3=B5geva', 10);
// abc j=\r\n
// =C3=B5geva
libqp
makes it possible to encode and decode streams with libqp.Encoder
and libqp.Decoder
constructors.
Create new Encoder Stream with
const encoder = new libqp.Encoder([options])
Where
lineLength
if you want to use any other line length than the default 76 characters (or set to false
to turn the soft wrapping off completely)Example
The following example script reads in a file, encodes it to Quoted-Printable and saves the output to a file.
var libqp = require('libqp');
var fs = require('fs');
var source = fs.createReadStream('source.txt');
var encoded = fs.createReadStream('encoded.txt');
var encoder = new libqp.Encoder();
source.pipe(encoder).pipe(encoded);
Create new Decoder Stream with
const decoder = new libqp.Decoder([options])
Where
Example
The following example script reads in a file in Quoted-Printable encoding, decodes it and saves the output to a file.
const libqp = require('libqp');
const fs = require('fs');
let encoded = fs.createReadStream('encoded.txt');
let dest = fs.createReadStream('dest.txt');
let decoder = new libqp.Decoder();
encoded.pipe(decoder).pipe(dest);
MIT
FAQs
Encode and decode quoted-printable strings according to rfc2045
The npm package libqp receives a total of 1,115,207 weekly downloads. As such, libqp popularity was classified as popular.
We found that libqp demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.