New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

endecoder

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

endecoder

A module can encode/decode strings with the keys.

Source
npmnpm
Version
1.3.1
Version published
Weekly downloads
18
20%
Maintainers
1
Weekly downloads
 
Created
Source

endecoder

A module can encode/decode strings with the keys.

npm NPM npms.io (quality) Libraries.io dependency status for latest release Maintenance

Installation

npm install endecoder

Usage

encode / decode easily

import { encode, decode } from "endecoder";

const PLAIN_TEXT = "this is a test string !#$%&'()";

const { data: encoded, options } = encode(PLAIN_TEXT);
// save options for decoding

const decoded = decode(encoded, options);

console.log(PLAIN_TEXT == decoded);
// true

more detailed

import { SecretKey } from "endecoder";

const PLAIN_TEXT = "this is a test string !#$%&'()";

const password = "testpassword!!#$%";
const salt = "salt///:*";

const key = SecretKey.activate({
  password,
  salt
});

const encoded = key.encode(PLAIN_TEXT);
console.log(encoded);

console.log(key.decode(encoded) == PLAIN_TEXT);
// true

// wrong password and salt combination
const alt_key = SecretKey.activate({
  password,
  salt: "salt///;*"
});

try{
  const decoded = alt_key.decode(encoded);
  console.log(decoded == PLAIN_TEXT);
  // will be false
}catch(error){
  // or an error may occur
}

Keywords

encryption

FAQs

Package last updated on 16 Aug 2022

Did you know?

Socket

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.

Install

Related posts