hesabe-crypt-ts
v1.0.8
Published
> Encryption library for Hesabe Payment API 2.0 for Typescript
Readme
hesabe-crypt-ts
Encryption library for Hesabe Payment API 2.0 for Typescript
Install
npm i -S hesabe-crypt-tsDependencies
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-ts/lib"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:
const secret = 'XXXXX' // Secret provided by Hesabe
const 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();You can now call the methods of hesabeCrypt.
let text = 'XXXXX'; // Any random text
let encrypted = instance.encryptAes(text, key, iv);
let decrypted = instance.decryptAes(encrypted, key, iv);

