diff --git a/README.md b/README.md index a4873b1..a109f52 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ There are 5 groups of functionalities in this module. You can require each one o ```js const { Base64, - Encription, + Encryption, Hash, Random, UUID diff --git a/docs/Encription.md b/docs/Encryption.md similarity index 60% rename from docs/Encription.md rename to docs/Encryption.md index 60c5d24..28b736c 100644 --- a/docs/Encription.md +++ b/docs/Encryption.md @@ -2,36 +2,36 @@ Run `npm run docs` to regenerate it. --> - + -## Encription -Handles string encription and decription +## Encryption +Handles string encryption and decription -* [Encription](#module_Encription) - * [.algorithms](#module_Encription.algorithms) - * [.unsafeEncrypt(plainTextString, [algorithm])](#module_Encription.unsafeEncrypt) ⇒ Promise.<string> - * [.unsafeDecrypt(encryptedString, [algorithm])](#module_Encription.unsafeDecrypt) ⇒ Promise.<string> +* [Encryption](#module_Encryption) + * [.algorithms](#module_Encryption.algorithms) + * [.unsafeEncrypt(plainTextString, [algorithm])](#module_Encryption.unsafeEncrypt) ⇒ Promise.<string> + * [.unsafeDecrypt(encryptedString, [algorithm])](#module_Encryption.unsafeDecrypt) ⇒ Promise.<string> - + -### Encription.algorithms +### Encryption.algorithms A key-value of the available algorithms: `AES128`, `AES192` and `AES256`. -**Kind**: static property of [Encription](#module_Encription) +**Kind**: static property of [Encryption](#module_Encryption) **Read only**: true **Example** ```js -doSomething(Encription.algorithms.AES128); +doSomething(Encryption.algorithms.AES128); ``` - + -### Encription.unsafeEncrypt(plainTextString, [algorithm]) ⇒ Promise.<string> -Encrypts a string using an encription algorithm and returns it in hex string format. +### Encryption.unsafeEncrypt(plainTextString, [algorithm]) ⇒ Promise.<string> +Encrypts a string using an encryption algorithm and returns it in hex string format. **IMPORTANT**: This method is not cryptographically secure. It uses a fixed non-random salt and initialization vector. -**Kind**: static method of [Encription](#module_Encription) +**Kind**: static method of [Encryption](#module_Encryption) **Returns**: Promise.<string> - Encrypted string in hex format | Param | Type | Default | Description | @@ -39,14 +39,14 @@ Encrypts a string using an encription algorithm and returns it in hex string for | plainTextString | string | | String to encrypt | | [algorithm] | algorithms | this.algorithms.AES128 | Algorithm to use for encrypt the string | - + -### Encription.unsafeDecrypt(encryptedString, [algorithm]) ⇒ Promise.<string> +### Encryption.unsafeDecrypt(encryptedString, [algorithm]) ⇒ Promise.<string> Decrypts a previously encrypted string with the specified algorithm **IMPORTANT**: This method is not cryptographically secure. It uses a fixed non-random salt and initialization vector -**Kind**: static method of [Encription](#module_Encription) +**Kind**: static method of [Encryption](#module_Encryption) **Returns**: Promise.<string> - Decrypted hex string | Param | Type | Default | Description | diff --git a/docs/README.md b/docs/README.md index ec2caaa..fc9284c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,7 +5,7 @@ Run `npm run docs` to regenerate it. --> See documentation for each module: - [Base64](Base64.md) -- [Encription](Encription.md) +- [Encryption](Encryption.md) - [Hash](Hash.md) - [Random](Random.md) - [UUID](UUID.md) diff --git a/lib/encription-algorithms.js b/lib/encryption-algorithms.js similarity index 100% rename from lib/encription-algorithms.js rename to lib/encryption-algorithms.js diff --git a/lib/encription.js b/lib/encryption.js similarity index 88% rename from lib/encription.js rename to lib/encryption.js index 4f2a187..b538b04 100644 --- a/lib/encription.js +++ b/lib/encryption.js @@ -3,7 +3,7 @@ const crypto = require('crypto'); const { promisify } = require('util'); -const { algorithms, getAlgorithmAttributes } = require('./encription-algorithms'); +const { algorithms, getAlgorithmAttributes } = require('./encryption-algorithms'); const scryptAsync = promisify(crypto.scrypt); @@ -11,23 +11,23 @@ const unsafeSalt = Buffer.alloc(16, 0); const initVector = Buffer.alloc(16, 0); /** - * @module Encription - * @description Handles string encription and decription + * @module Encryption + * @description Handles string encryption and decription */ -module.exports = class Encription { +module.exports = class Encryption { /** * A key-value of the available algorithms: `AES128`, `AES192` and `AES256`. * * @readonly - * @example doSomething(Encription.algorithms.AES128); + * @example doSomething(Encryption.algorithms.AES128); */ static get algorithms() { return algorithms; } /** - * Encrypts a string using an encription algorithm and returns it in hex string format. + * Encrypts a string using an encryption algorithm and returns it in hex string format. * * **IMPORTANT**: This method is not cryptographically secure. It uses a fixed non-random salt and initialization vector. * diff --git a/lib/index.js b/lib/index.js index 9d2c227..a0fa0f3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,14 +2,14 @@ const Base64 = require('./base64'); const Hash = require('./hash'); -const Encription = require('./encription'); +const Encryption = require('./encryption'); const Random = require('./random'); const UUID = require('./uuid'); module.exports = { Base64, Hash, - Encription, + Encryption, Random, UUID }; diff --git a/tests/encription.js b/tests/encryption.js similarity index 61% rename from tests/encription.js rename to tests/encryption.js index afedd94..60f9fa4 100644 --- a/tests/encription.js +++ b/tests/encryption.js @@ -2,9 +2,9 @@ const assert = require('assert'); -const { Encription } = require('../lib'); +const { Encryption } = require('../lib'); -describe('Encription', () => { +describe('Encryption', () => { const plainTextString = 'Hi there, I am a test'; const encodedStringWithAES128 = '26ffc79ef45a8d6ff461cf3fa6ff8b67b7545347d3b5d18d904a2c85d4ec08f5'; @@ -13,12 +13,12 @@ describe('Encription', () => { describe('algorithms getter', () => { - it('Should return an object with the encription algorithms enum', () => { - assert(Encription.algorithms); - assert.strictEqual(typeof Encription.algorithms, 'object'); - assert.strictEqual(Encription.algorithms.AES128, 'AES128'); - assert.strictEqual(Encription.algorithms.AES192, 'AES192'); - assert.strictEqual(Encription.algorithms.AES256, 'AES256'); + it('Should return an object with the encryption algorithms enum', () => { + assert(Encryption.algorithms); + assert.strictEqual(typeof Encryption.algorithms, 'object'); + assert.strictEqual(Encryption.algorithms.AES128, 'AES128'); + assert.strictEqual(Encryption.algorithms.AES192, 'AES192'); + assert.strictEqual(Encryption.algorithms.AES256, 'AES256'); }); }); @@ -26,17 +26,17 @@ describe('Encription', () => { describe('unsafeEncrypt()', () => { it('Should resolve the encripted string using AES128 by default', async () => { - const encriptedString = await Encription.unsafeEncrypt(plainTextString); + const encriptedString = await Encryption.unsafeEncrypt(plainTextString); assert.strictEqual(encriptedString, encodedStringWithAES128); }); it('Should resolve the encripted string using a AES192 algorithm if passed as param', async () => { - const encriptedString = await Encription.unsafeEncrypt(plainTextString, Encription.algorithms.AES192); + const encriptedString = await Encryption.unsafeEncrypt(plainTextString, Encryption.algorithms.AES192); assert.strictEqual(encriptedString, encodedStringWithAES192); }); it('Should resolve the encripted string using a AES256 algorithm if passed as param', async () => { - const encriptedString = await Encription.unsafeEncrypt(plainTextString, Encription.algorithms.AES256); + const encriptedString = await Encryption.unsafeEncrypt(plainTextString, Encryption.algorithms.AES256); assert.strictEqual(encriptedString, encodedStringWithAES256); }); @@ -45,17 +45,17 @@ describe('Encription', () => { describe('unsafeDecrypt()', () => { it('Should resolve the plain text string using AES128 by default', async () => { - const decriptedString = await Encription.unsafeDecrypt(encodedStringWithAES128); + const decriptedString = await Encryption.unsafeDecrypt(encodedStringWithAES128); assert.strictEqual(decriptedString, plainTextString); }); it('Should resolve the plain text string using a AES192 algorithm if passed as param', async () => { - const decriptedString = await Encription.unsafeDecrypt(encodedStringWithAES192, Encription.algorithms.AES192); + const decriptedString = await Encryption.unsafeDecrypt(encodedStringWithAES192, Encryption.algorithms.AES192); assert.strictEqual(decriptedString, plainTextString); }); it('Should resolve the plain text string using a AES256 algorithm if passed as param', async () => { - const decriptedString = await Encription.unsafeDecrypt(encodedStringWithAES256, Encription.algorithms.AES256); + const decriptedString = await Encryption.unsafeDecrypt(encodedStringWithAES256, Encryption.algorithms.AES256); assert.strictEqual(decriptedString, plainTextString); });