UNPKG

encrypto-decrypto

Version:

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

46 lines (34 loc) 1.07 kB
# 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`<br /> _must be 32 characters long_ `iv`<br /> _must be 16 characters long_ ### Optional Parameters `algorithm` [Defaults to _aes-256-cbc_] <br /> _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_] <br /> _must be one of: utf8, ascii, latin1_ `outputEncoding` [Defaults to _hex_] <br /> _must be one of: hex, base64, latin1_ ## License [MIT](./LICENSE)