Code Monkey home page Code Monkey logo

rsa-algorithm's Introduction

RSA Algorithm Implementation in Python

Overview

This project implements the RSA (Rivest–Shamir–Adleman) algorithm, a popular asymmetric encryption and decryption method, using Python. RSA is widely used for secure data transmission in modern computing. The implementation allows users to encrypt and decrypt text using RSA, providing insights into the algorithm's mechanics.

Features

  • RSA algorithm for encryption and decryption
  • Reading plaintext from a file or input
  • Prime number validation for keys
  • ASCII conversion for text encryption and decryption

Prerequisites

  • Python 3.x
  • sympy library for prime number validation

Installation

  1. Clone the repository:
    git clone https://github.com/AbdelrahmanBayoumi/RSA-Algorithm-in-Cryptography.git
  2. Install the required Python library:
    pip install sympy

Usage

To use this program:

  1. Run main.py.
  2. Input two prime numbers (p and q) when prompted.
  3. Choose to read from a file (f) or input plaintext (m).
  4. The program will display the encrypted and decrypted message.

Example

Enter p: 17
Enter q: 19
Enter:-
    - 'f' to read from file => msg.txt.
    - 'm' to enter plaintext message.
f

Algorithm Explanation

description

RSA algorithm involves the following steps:

  1. Select two large prime numbers p and q. Calculate n = p * q and t = (p - 1) * (q - 1).
  2. Choose an encryption key e such that 1 < e < t and gcd(e, t) == 1.
  3. Determine the decryption key d satisfying d * e = 1 (mod t).
  4. For encryption, convert plaintext to ASCII and compute C = (P ^ e) % n.
  5. For decryption, convert cipher text back using P = (C ^ d) % n.

Contributing

Contributions to this project are welcome. Please follow standard GitHub contribution guidelines.

Acknowledgements

Developed by Abdelrahman Bayoumi - GitHub. Course project for Algorithm Analysis and Design CS305, Faculty of Science, Alexandria University.

سبحَانَكَ اللَّهُمَّ وَبِحَمْدِكَ، أَشْهَدُ أَنْ لا إِلهَ إِلأَ انْتَ أَسْتَغْفِرُكَ وَأَتْوبُ إِلَيْكَ.

rsa-algorithm's People

Contributors

abdelrahmanbayoumi 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.