@postnord/pretty-crypto
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @postnord/pretty-crypto

Weekly Downloads

1,007

Version

0.0.8

License

Proprietary

Unpacked Size

5.72 kB

Total Files

4

Last publish

Collaborators

  • mipe-pn
  • vbacalso
  • jkaske-pn
  • pn-webteam
  • postnord.npm
  • ghassen.cheniour
  • jay.falcon
  • vbrigoli
  • jvalmores
  • frqu300
  • access-login-publisher
  • joakim.hedlund.postnord
  • pn-aronsson
  • m.usman
  • mahadiapn
  • ambots13
  • kheycee.matarlo
  • pnorbert
  • pnncp-aftersales
  • junlue-pn
  • avsceriola-pn
  • vanessa.faith.abordo.postnord
  • sesam-publisher
  • pn-chester
  • pn-foundation-deployer
  • pn-jroma
  • sabbir-rahman-sakib
  • mathias.billing
  • raymund.galapate
  • sculaste
  • pn-akilumanga
  • cielomuyot.postnord
  • oaipostnord
  • ncppublicservice
  • romeo.obane
  • adamkillander
  • postnord.aldee_mativo
  • retail-team-npm
  • pn-ost-base
  • sang-canencia-npm-pn
  • nizamuddeen.tz
  • pn_rroble
  • aliaksei.stryi-postnord
  • damiant-postnord
  • johan_natoft
  • bernhardhettman-pn
  • fbopdin
  • ashwin_postnord
  • rnishimura
  • xtic
  • anadinema
  • vibhormungee
  • akhilkkuriakose
  • p_teodor