TypeScript
📦 Installation
📦
NPM Installation
You can install the encryption library for TypeScript using npm:
npm i -S hesabe-crypt-ts
🔧 Dependencies
🔗
Required Dependencies
A dependency for this package aes-js
will also get installed automatically and usage is shown below.
🛠️ Usage Guide
1
Import HesabeCrypt Class
After installing the library, import the Hesabe Crypt class:
import {`{HesabeCrypt}`} from "hesabe-crypt-ts/lib"
2
Import AES-JS
You also need to import aes-js
:
import aesjs from "aes-js"
3
Setup Keys
You need to have a secret and an IV code. Convert your secret and IV to bytes:
const secret = 'XXXXX' // Secret key provided by Hesabe
const ivCode = 'XXXXX' // IV key provided by Hesabe
key = aesjs.utils.utf8.toBytes(secret);
iv = aesjs.utils.utf8.toBytes(ivKey);
4
Initialize Instance
Initialize an instance of the hesabeCrypt class:
let instance = new HesabeCrypt();
✓
Use Encryption/Decryption
Now you can call the methods of hesabeCrypt for encryption and decryption:
let text = 'XXXXX'; // Any data to encrypt
let encrypted = instance.encryptAes(text, key, iv);
let decrypted = instance.decryptAes(encrypted, key, iv);
📥 Example Kit & Support
📦
React Example Kit
Complete TypeScript integration kit with React examples