Skip to content
/ rsa_js Public

Simple package to handle RSA encryption and decryption algorithm

Notifications You must be signed in to change notification settings

teguh02/rsa_js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

Simple package to handle RSA encryption and decryption algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published