1.2.1 • Published 1 year ago

@rgwch/simple-crypt v1.2.1

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

Simple-Crypt.ts

A simple typescript-wrapper around encrypting Node-Buffers and Streams. To make automated brute-force attacks (slightly) more difficult, it adds a simple pre-encrypt transform step.

Installation

npm i --save @rgwch/simple-crypt

Usage

With Streams:

import {Crypter} from '@rgwch/simple-crypt'
const crypter=new Crypter("super safe passphrase","program specific salt")
const instream=someDataFromSomewhere()
const outstream="sendDateThere()

crypter.encrypt(instream,outstream).then(()=>{
  console.log("success")
}.catch(err=>{
  console.log("Something went wrong: "+err)
})

crypter.decrypt(encryptedStream,outstream).then(()=>{
  console.log("success")
}).catch(err=>{
  console.log("something went wrong: "+err)
})

With Buffers:

import {Crypter} from '@rgwch/simple-crypt'
const crypter=new Crypter("super safe passphrase","program specific salt")
const input=Buffer.from("A Buffer with some data")
const encrypted=await crypter.encryptBuffer(input)

const output=await crypter.decryptBuffer(encrypted)
console.log(output.toString())  // A Buffer with some data

Test

npm test

License

BSD

1.2.0

1 year ago

1.2.1

1 year ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago