0.0.8 • Published 1 year ago

@postnord/pretty-crypto v0.0.8

Weekly downloads
-
License
Proprietary
Repository
-
Last release
1 year ago

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

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago