Skip to content

tarunv98/RSA-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RSA Algorithm 1.0

An RSA implementation in NodeJS

RSA wiki

This is an RSA calculator to compute prime numbers(p, q), mod value, psi value, public and private exponents. You can also perform string encryption and decryption.

Features:

  • Calculating primes(p, q), mod value(n), psi value(psi), public exponent(e) and private exponent(d).
  • All values are generated based on one input which is size of mod (n) (in bits)
  • String encryption and decryption.

Algorithm:

Suppose the required size of mod value is 16bits.

  1. Generate two prime numbers (p, q) such that the size of their product (which is mod value, n) is 16.
n = p * q
  1. Calculate psi value.
psi = (p-1) * (q-1)
  1. Compute a public exponent (e) such that e and psi are co-primes and 0 < e < psi.
e
  1. Compute private exponent (d).
For a constant k, d = (k*psi + 1)/e; such that (k*psi + 1) % e = 0
  1. For encryption
c = (t^e) % n
  1. For decryption
t = (c^d) % n

Example:

  • size = 16bits
  • p = 181; q = 191;
  • n =p*q = 34571
  • psi = (p-1)(q-1) = 34200
  • e = 7
  • d = 19543

Instructions:

  1. Clone the Repo
  2. Install dependencies
npm install
  1. Check index.js file for implementation

✌️Thats it!!✌️

PS: The maximum acceptable size of mod value is 31

About

An RSA implementation in NodeJS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published