Code Monkey home page Code Monkey logo

rsa_algorithm's Introduction

RSA Algorithm

Simple implementation of RSA algorithm, asymmetric cryptography algorithm

The concept of RSA Algorithm is generating public and private keys in 512 bits.

Screenshot

The Algorithm theory:

1- Key Generation

• Choose two random prime numbers p & q using Miller-Rabin Test
• Compute n =p*q
• Compute euler phi = (p-1) (q-1)
• Choose e, random prime number in specific range
• Then get the key of (n,e)

2- Message Encryption using EEA (Extended Euclidean algorithm)

• C = m^e mod n

3- Message Decryption using CRT

• C^d mod n
• e^-1 mod phi

• Miller-Rabin Test

1- Get U & R from the prime number
2- Use Square and multiply algorithm to allow fast exponentiaition

• CRT

1- Modular representation of y into p and q

𝑦𝑝=𝑦 𝑚𝑜𝑑 𝑝 
𝑦𝑞=𝑦 𝑚𝑜𝑑 𝑞 

2- Compute exponents

𝑑𝑝=𝑑 𝑚𝑜𝑑 (𝑝−1) 
𝑑𝑞=𝑑 𝑚𝑜𝑑 (𝑞−1) 

3- Compute exponentiation

𝑥𝑝=𝑦𝑝𝑑𝑝 𝑚𝑜𝑑 𝑝
𝑥𝑞=𝑦𝑞𝑑𝑞 𝑚𝑜𝑑 𝑞

4- Compute C:

𝐶𝑝=𝑞−1 𝑚𝑜𝑑 𝑝 
𝐶𝑞=𝑝−1 𝑚𝑜𝑑 𝑞 

5- Compute X

𝑋 = {(𝑞.𝐶𝑝)𝑋𝑝 + (𝑝.𝐶𝑞) 𝑋𝑞} 𝑚𝑜𝑑 𝑛 

rsa_algorithm's People

Contributors

mohamedhashim avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

snehal498

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.