1.0.3 • Published 5 years ago

flk-crypto v1.0.3

Weekly downloads
21
License
-
Repository
github
Last release
5 years ago

Crypto

A simple Encryption/Decryption handler.

The current followed encryption algorithm is AES.

Installation

flk install flk-crypto

OR

npm install flk-crypto

Alias: crypto.

Table of contents

Usage

  let crypto = DI.resolve('crypto');

  let encryptedValue = crypto.encrypt('hello world');

Available methods

encrypt

encrypt(value: any): String Encrypt the given value.

This method accepts any type of values, it will be handled automatically, that means you can encrypt scalar values (string|boolean|number), arrays or objects.

Examples

  let crypto = DI.resolve('crypto');

  let encryptedValue = crypto.encrypt('hello world');

  // encrypt objects
  let user = {
    name: 'Hasan',
    age: 30,
  };

  let encryptedObject = crypto.encrypt(user);

Decrypt

decrypt(encodedValue: String): any|null Decrypt the given encoded value.

Examples

let user = crypto.decrypt('some-encoded-value');

Configurations

Available configurations for crypto in Application configurations.

Main Configuration key: crypto

keyTypeDescription
keyStringSet the encryption/decryption key, by default it is the current application name.
1.0.3

5 years ago

1.0.2

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago