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

0.0.5 • 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

873

Version

0.0.5

License

Proprietary

Unpacked Size

5.92 kB

Total Files

4

Last publish

Collaborators

  • cielomuyot.postnord
  • pn_rroble
  • damiant-postnord
  • erikedling
  • adamkillander
  • sculaste
  • bernhardhettman-pn
  • ashwin_postnord
  • fbopdin
  • elrmndo_pn
  • aliaksei.stryi-postnord
  • sang-canencia-npm-pn
  • pn-ost-base
  • retail-team-npm
  • eriklind-pn
  • postnord.aldee_mativo
  • raymund.galapate
  • romeo.obane
  • elias_sidenbladh
  • ncppublicservice
  • oaipostnord
  • pn-jroma
  • pn-foundation-deployer
  • pn-chester
  • pn-akilumanga
  • sabbir-rahman-sakib
  • jkaske-pn
  • pnrutbergphilip
  • pnorbert
  • kheycee.matarlo
  • johankarlsson-pn
  • sesam-publisher
  • vanessa.faith.abordo.postnord
  • avsceriola-pn
  • junlue-pn
  • pnncp-aftersales
  • mipe-pn
  • vbacalso
  • jonas_elfstrom
  • pn-webteam
  • postnord.npm
  • vbrigoli
  • jvalmores
  • vijilgirish
  • frqu300
  • access-login-publisher
  • joakim.hedlund.postnord
  • pn-fipe
  • pn-aronsson
  • m.usman
  • mahadiapn
  • ambots13