2.0.5 • Published 6 years ago
hesabe-crypt v2.0.5
hesabe-crypt
Encryption library for Hesabe Payment API 2.0
Install
npm i -S hesabe-cryptDependencies
A depency for this package aes-js will also get installed automatically and usage of that is shown below.
Usage
After installing this library you may import the Hesabe Crypt class.
import hesabeCrypt from "hesabe-crypt";You need to import aes-js also.
import aesjs from "aes-js";You need to have a secret and an iv code to use this package.
Before starting encryption, you need to convert your secret and iv in bytes mentioned below:
let secret = 'XXXXX' // Secret provided by Hesabe
let ivCode = 'XXXXX' // IV provided by Hesabe
key = aesjs.utils.utf8.toBytes(secret);
iv = aesjs.utils.utf8.toBytes(ivKey);You first need to initialise an intance of hesabeCrypt class and pass the key and iv while doing it.
let instance = new hesabeCrypt(key, iv);You can now call the methods of hesabeCrypt.
let text = 'XXXXX'; // Any random text
let encrypted = instance.encryptAes(text);
let decrypted = instance.decryptAes(encrypted);