A simple TypeScript module to encrypt data using a private key and send it to a specified API endpoint.
- Generates a private key if not already present.
- Encrypts data using the private key.
- Sends encrypted data to a specified API endpoint.
Clone the repository:
git clone https://github.com/your-username/encryption-module.git
cd encryption-module
Install the dependencies:
npm install
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.
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);
});
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.