hesabe-crypt
Encryption library for Hesabe Payment API 2.0
Install
npm i -S hesabe-crypt
Dependencies
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 Hesabelet ivCode = 'XXXXX' // IV provided by Hesabe key = aesjs.utils.utf8.toBytes;iv = aesjs.utils.utf8.toBytes;
You first need to initialise an intance of hesabeCrypt
class and pass the key
and iv
while doing it.
let instance = new hesabeCrypt;
You can now call the methods of hesabeCrypt
.
let text = 'XXXXX'; // Any random textlet encrypted = instance.encryptAes; let decrypted = instance.decryptAes;