Skip to content

GHR-Arash/Hadal-Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Encryption Module

A simple TypeScript module to encrypt data using a private key and send it to a specified API endpoint.

Features

  • Generates a private key if not already present.
  • Encrypts data using the private key.
  • Sends encrypted data to a specified API endpoint.

Installation

Clone the repository:

git clone https://github.com/your-username/encryption-module.git
cd encryption-module

Install the dependencies:

npm install

Configuration

Create a config.json in the root directory with the following structure:

{
  "privateKeyPath": "./privateKey.pem",
  "apiAccessKey": "YOUR_API_ACCESS_KEY",
  "apiEndpoint": "https://api.example.com/endpoint"
}
  • privateKeyPath: Path to the private key. If the key doesn't exist, one will be generated.
  • apiAccessKey: Access key for the API.
  • apiEndpoint: API endpoint to send encrypted data.

Usage

To use this module in another application:

import EncryptionModule from './path-to-encryption-module';

const module = new EncryptionModule('./config.json');
module.encryptAndSend('Hello, World!', 'YOUR_EXTERNAL_ID')
    .then(refrenceId => {
        console.log('Received refrenceId:', refrenceId);
    })
    .catch(error => {
        console.error('Failed to send data:', error);
    });

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published