Giter VIP home page Giter VIP logo

sahil-4555 / rsa-encryption Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 1.0 118 KB

RSA algorithm is an asymmetric cryptography algorithm. Asymmetric actually means that it works on two different keys i.e. Public Key and Private Key. The public key consists of two numbers where one number is a multiplication of two large prime numbers. And private key is also derived from the same two prime numbers.

C++ 42.10% Go 57.90%
algorithm cipher-algorithms cryptography rsa-cryptography rsa-encryption encryption-decryption rc4 rsa-cryptosystem rsa-decryption cpp

rsa-encryption's Introduction

RSA algorithm (Rivest-Shamir-Adleman)

This code implements the RSA encryption and decryption algorithm. It generates random prime numbers, calculates the public and private keys, encrypts and decrypts messages using these keys.

Functionality

The code performs the following steps:

  1. Generates two random prime numbers, p and q, of the specified number of bits.

  2. Calculates the modulus n as the product of p and q.

  3. Calculates the Euler's totient function phi as (p-1) * (q-1).

  4. Finds the optimal value of e that is relatively prime to phi.

  5. Displays the generated prime numbers (p and q), modulus (n), Euler's totient function (phi), and the public key (e, n).

  6. Encrypts the input plain text message using the public key to obtain the ciphertext.

  7. Displays the encrypted ciphertext.

  8. Calculates the private key d as the modular multiplicative inverse of e modulo phi.

  9. Decrypts the ciphertext using the private key to obtain the original plain text message.

  10. Displays the decrypted plain text message.

Go Implementation

Run The main.go file Using Command:

go run main.go

Output

RSA_GO_IMPLEMENTATION

C++ Implementation

Run The RSA.cpp file Using Command:

g++ RSA.cpp -o rsa

Once the compilation process is successful, you can execute the compiled program. To run the program, use the following command:

./rsa

Output

RSA_C++_IMPLEMENTATION

Customization

  • You can modify the number of bits for the generated prime numbers by changing the numBits variable in the solve() function.

Acknowledgments

  • The code is based on the RSA algorithm for encryption and decryption.
  • The Miller-Rabin primality test is used to generate random prime numbers.
  • The modular exponentiation and extended Euclidean algorithm functions are adapted from standard algorithms.

rsa-encryption's People

Contributors

sahil-4555 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.