Skip to content

digitalsweetspot/encrypto-decrypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

encrypto-decrypto


Provides simple encryption and decryption services based on node's crypto functionality.


How to install

npm install encrypto-decrypto

How to use

const encrypto_decrypto = require('encrypto-decrypto')

const encryptoDecrypto = new encrypto_decrypto({
  key: 'someReallyLongStringToUseAsAKey!',
  iv: 'nonceString4Key!'
})

const encStr = encryptoDecrypto.encrypt('Hello World!')
console.log(encStr) // 65f1702da3ac2e2d28e4a972d3b955a4

const decrStr = encryptoDecrypto.decrypt('65f1702da3ac2e2d28e4a972d3b955a4')
console.log(decrStr) // Hello World!

Required Parameters

key
must be 32 characters long

iv
must be 16 characters long

Optional Parameters

algorithm [Defaults to aes-256-cbc]
must be one of: aes-128-cbc, aes-192-cbc, aes-256-cbc, aes-128-ctr, aes-192-ctr, aes-256-ctr

inputEncoding [Defaults to utf8]
must be one of: utf8, ascii, latin1

outputEncoding [Defaults to hex]
must be one of: hex, base64, latin1

License

MIT