1 | # Encryption SE
|
2 |
|
3 | [![NPM Version](https://img.shields.io/npm/v/encryption-se.svg?style=flat)](https://www.npmjs.org/package/encryption-se)
|
4 | [![NPM Downloads](https://img.shields.io/npm/dm/encryption-se.svg?style=flat)](https://npmcharts.com/compare/encryption-se?minimal=true)
|
5 | [![Install Size](https://packagephobia.now.sh/badge?p=encryption-se)](https://packagephobia.now.sh/result?p=encryption-se)
|
6 | [![CircleCI](https://circleci.com/bb/SeaExc/se.security.encryption.svg?style=shield)](https://circleci.com/bb/SeaExc/se.security.encryption)
|
7 | [![Coverage Status](https://coveralls.io/repos/bitbucket/SeaExc/se.security.encryption/badge.svg?branch=master)](https://coveralls.io/bitbucket/SeaExc/se.security.encryption?branch=master)
|
8 |
|
9 | ### Description
|
10 | A simple module wrapping around NodeJS Crypto module allowing handling IV by prefixing it to encrypted string.
|
11 |
|
12 | ## Options
|
13 | Name | Default | Description
|
14 | :--- | --- | :---
|
15 | `password` | `null` | Password secret **REQUIRED**
|
16 | `passwordSalt` | `This is my salt 362` | Password salt
|
17 | `iterationCount` | `100000` | Number of iterations for PBKDF2
|
18 | `encryptionKey` | `null` | Encryption key as array of bytes
|
19 |
|
20 | ### How to use it
|
21 | #### Installation
|
22 |
|
23 | ```shell
|
24 |
|
25 | // First you have to get module and instantiate it
|
26 |
|
27 | npm install encryption-se
|
28 |
|
29 | OR
|
30 |
|
31 | yarn add encryption-se
|
32 |
|
33 | ```
|
34 |
|
35 | After installing module, add this to your code:
|
36 |
|
37 | ```javascript
|
38 | const options = {
|
39 | password: process.env.encryptionPassword || 'SomePassword'
|
40 | };
|
41 |
|
42 | const encryption = require('encryption-se')(options);
|
43 | ```
|
44 |
|
45 | #### How to encrypt?
|
46 | ```javascript
|
47 | encryption
|
48 | .encrypt('This is to be encrypted')
|
49 | .then(enc => {
|
50 | // 'enc' contains encrypted string in base64 format
|
51 | })
|
52 | .catch((err) => {
|
53 | // This is to handle errors
|
54 | })
|
55 | ```
|
56 |
|
57 | #### How to decrypt?
|
58 | ```javascript
|
59 | encryption
|
60 | .decrypt('iQ6qlRWlwWXtmGPFbBiEc4WKKAbHCLQK0+HLxoGLKY0=')
|
61 | .then((text) => {
|
62 | // 'text' contains decrypted string
|
63 | })
|
64 | .catch((err) => {
|
65 | // This is to handle errors
|
66 | })
|
67 | ```
|
68 |
|
69 | ### Contact
|
70 |
|
71 | [![Image](https://static-exp1.licdn.com/scds/common/u/images/logos/linkedin/logo_linkedin_93x21_v2.png)](https://www.linkedin.com/in/mihovilstrujic) |
\ | No newline at end of file |