@teguh02/rsa_js

1.0.3 • Public • Published

Package Information

@teguh02/rsa_js is a simple package to handle RSA encryption and decryption algorithm.

This javascript library are couples from this php library https://github.com/teguh02/rsa_php

Installation

If you want to install this library you can install with this command npm i @teguh02/rsa_js

Usage

// Import the RSA module
import RSA  from '../src/RSA.mjs';

// Define p and q
const p = 61;
const q = 53;

// Generate the RSA public and private keys
const keys = RSA.generateKeys(p, q);

// Print the public and private keys
// console.log("Public key: ", keys.publicKey);
// console.log("Private key: ", keys.privateKey);

// Define the message
const message = "I LOVE YOU"; 

// Encrypt the message
const encryptedMessage = RSA.encrypt(message, keys.publicKey);
console.log("Encrypted message: ", encryptedMessage.join(","));

// Decrypt the message
const decryptedMessage = RSA.decrypt(encryptedMessage, keys.privateKey);
console.log("Decrypted message: ", decryptedMessage);

// Also you can receive the message in this way from the RSA PHP library:
// const decryptedMessage = RSA.decrypt('286,2774,83,913,1781,155,2774,206,913,2509', keys.privateKey);

Package Sidebar

Install

npm i @teguh02/rsa_js

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

12 kB

Total Files

5

Last publish

Collaborators

  • teguh02