🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@postnord/pretty-crypto

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@postnord/pretty-crypto

Safely encrypt and decrypt asynchronous through Promises

0.0.8
latest
npm
Version published
Maintainers
0
Created
Source

A library that handles the hustle of implementing a safe, efficient and asynchronous set of methods to handle encryption and decryption. It also exposes the interfaces necessary to work with JWT.

Installation

npm i @postnord/pretty-crypto

const myService = new CryptoMethods('xmEdy63WE2LCdvIJMdfwstD4e7aXINxG', 'jwfknefne', 'jwtsecret')

const raw = 'Hi there!'
const encrypted = await myService.encrypt(raw)
const decrypted = await myService.decrypt(encrypted)
expect(decrypted).toBe(raw)

const input = { k: 'v' }
const encoded = await myService.jwtEncode(input)
const decoded = await myService.jwtDecode(encoded)
expect(decoded).toEqual(input)

API

CryptoMethods(signingKey: string, ivKey: string, jwtKey: string)

Will initialize the class.

encrypt(rawInput: string): Promise<string>

Will return the encrypted string.

decrypt(encryptedInput: string): Promise<string>

Will return the decrypted string.

jwtEncode(input: object): Promise<string>

Will return the signed JWT string.

jwtDecode(input: string): Promise<object>

Will return the decoded JWT object

FAQs

Package last updated on 04 Jul 2024

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