项目作者: AbdelrahmanBayoumi

项目描述 :
Implementation of RSA Algorithm (Encryption - Decryption)
高级语言: Python
项目地址: git://github.com/AbdelrahmanBayoumi/RSA-Algorithm.git
创建时间: 2019-12-19T16:20:44Z
项目社区:https://github.com/AbdelrahmanBayoumi/RSA-Algorithm

开源协议:

下载


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:
    1. git clone https://github.com/AbdelrahmanBayoumi/RSA-Algorithm-in-Cryptography.git
  2. Install the required Python library:
    1. 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

  1. Enter p: 17
  2. Enter q: 19
  3. Enter:-
  4. - 'f' to read from file => msg.txt.
  5. - 'm' to enter plaintext message.
  6. 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.

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