0.0.4 • Published 3 years ago

aif-cipher v0.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

aif-cipher

Implementation of aes-256-cbc, base64, and md5

A set of basic AES implementation functions aes-256-cbc for encryption and decryption of data packets that can be used to send information to servers compatible with openssl libraries.

Installation

Download the library with npm / Yarn, from your local files.

Via NPM:

$ npm install aif-cipher

Via YARN:

$ yarn add aif-cipher

Or you can export to the browser, using one of these tools: Browserify, Webmake o Webpack

Use

The library can be included in your code through imports from CommonJS or ES.

ES2015 (ES6):

import * as cipher from "aif-cipher";

CommonJS:

var cipher = require("aif-cipher");

With ES imports it is also possible to use individual components. For example:

import { aesEncode, aesDecode, md5 } from "aif-cipher";

Configuración

The initialization of the credentials is optional, since if it is not defined from here, the encryption methods can be passed directly to the arguments.

var cipher = require("aif-cipher");

var secret = '-secret-';
var token = cipher.md5('-token-');

cipher.aesSetCredentials(secret, token);

if Token is set, it must be 32 characters.

Methods

md5(string)

base64Encode(data)

base64Decode(data)

aesSetCredentials(secret, token)

aesDecode(string, secret, token)

aesEncode(string, secret, token)

Example using the credential definition:

var cipher = require("aif-cipher");

var hash = cipher.md5('-valor-');
console.log('md5:', hash);

var data = cipher.aesEncode('-valor-', '-secret-', cipher.md5('-token-'));
console.log('encode:', data)

data = cipher.aesDecode(data, '-secret-', cipher.md5('-token-'));
console.log('decode:', data)

Example using the credential definition:

var cipher = require("aif-cipher");

var secret = '-secret-';
var token = cipher.md5('-token-');
cipher.aesSetCredentials(secret, token);

var data = cipher.aesEncode('-valor-');
console.log('encode:', data)

data = cipher.aesDecode(data);
console.log('decode:', data)

Tests

$ npm test

O well

$ yarn test

build

$ npm run build

O well

$ yarn build

Security contact information

To report security vulnerabilities, use the following link: https://github.com/mygnet/aif-cipher/issues


0.0.3

3 years ago

0.0.4

3 years ago

0.0.2

4 years ago

0.0.1

4 years ago