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

encrypt-decrypt-library

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

encrypt-decrypt-library

Encryption Library

latest
npmnpm
Version
1.0.5
Version published
Weekly downloads
25
-40.48%
Maintainers
1
Weekly downloads
 
Created
Source

CircleCI semantic-release semantic-release

encrypt-decrypt-library

Simple Encryption Library for encrypting strings and integers into unique tokens, safe for use in URL paths and queries. Supports 64bit signed and unsigned big endians.

Install

// Via NPM
$ npm install --save encrypt-decrypt-library

// Via Yarn
$ yarn add encrypt-decrypt-library

Usage

import Encryption from "encrypt-decrypt-library";

const config = {
   algorithm: process.env.ALGORITHM,
   encryptionKey: process.env.ENCRYPTION_KEY,
   salt: process.env.SALT,
} 
const encryption = new Encryption(config);

encryption.encrypt('Hello world')
// xxxxxxx

Documentation

The library requires the following configuration options:

  • algorithm: String - The algorithm type to be used by the library

  • encryptionKey: String - The encryption key to be used by the library

  • salt: String - The salt to be used by the library

encrypt(value: string, isInt: boolean)

Returns an encrypted value.

value

Type: string - The value that will be encrypted.

isInt

Type: boolean (optional) - The type of value. Provides support for Big Integer encryption.

Example

import Encryption from "encrypt-decrypt-library";

const config = {
   algorithm: process.env.ALGORITHM,
   encryptionKey: process.env.ENCRYPTION_KEY,
   salt: process.env.SALT,
} 
const encryption = new Encryption(config);

// Encrypted as a string
encryption.encrypt('Hello world')

// Encrypted as a string
encryption.encrypt('1234567890')

// Encrypted as an unsigned 64-bit Integer
encryption.encrypt(123, true)

decrypt(value: string, isInt: boolean)

Returns a decrypted value.

value

Type: string - The token that will be decrypted.

isInt

Type: boolean (optional) - The type of encrypted value if known. Provides support for decrypting small and big integers.

Example

import Encryption from "encrypt-decrypt-library";

const config = {
   algorithm: process.env.ALGORITHM,
   encryptionKey: process.env.ENCRYPTION_KEY,
   salt: process.env.SALT,
} 
const encryption = new Encryption(config);

// Encoded as string
encryption.decrypt('gmmBh17Q4QA=')
// xxx

// Encoded as an integer
encryption.decrypt('NF1r855MimY=', true)
// xxx 

Semantic release

Release management is automated using semantic-release.

License

The MIT License

FAQs

Package last updated on 30 Apr 2021

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