This repository contains a code project I realized during my time at Code Chrysalis.
This project aims to demistify the RSA algorithm, or the idea of Public Key/Private Key concepts.
In actual usage, for obvious security reasons, the numbers used are huge and as a result it is difficult to understand how things work.
I tried to implement by myself the RSA algorithm with small numbers, to try to understand how the model works below the hood.
This page is accessible on Github pages at the following address: https://alixfachin.github.io/easyCrypto/
Please kindly remember that this project is meant for teaching/understanding and as a result please do not use the results to encode sensitive information. I cannot be responsible for damage or negative outcomes following using this program with personal and/or sensitive information.
- The package uses
npm
package manager. - Download or clone the repository
- Run
npm install
- Run
npm run start
to start the development server. You should be able to see the page with any browser on yourlocalhost:3000
address.
The page has two distinct parts:
- 🗝 Key Generator: to try to understand what is the principle used to find public and private keys.
- 🥷Encoding/Decoding: Once we have a public key/private key, we can put it in practice and encode/decode any message. (Without emojis, please.)
A public key will in our case be a couple of integers (a,b)
.
The private key is constitued of another integer p
, which, associated with the second key b
makes the private key (p,b)
.
- We will transform characters into number, so we can assume that we want to transmit a sequence of numbers.
- In order to encode a character of code
c
, we takec
to the powera
.- The encoded character code will be the remainder of
c^a
byb
, so(c^a mod b)
.
- The encoded character code will be the remainder of
- In order to decode an encoded character, we can take the encoded character
e
and proceed with a similar operation, but this time with the private keyp
, i.e.e^p mod b
. - If we choose
a
,b
andp
wisely, we can assure that(c^a mod b)^p mod b = c
so we have decoded the message.
- As mentioned above, we need to choose
a
,b
andp
wisely, so that the operation works, but as well so that it is very difficult for anyone else to figure outp
(the private key) while knowinga
andb
(which are public). - Prime numbers have very interesting properties, and combining prime numbers with circular arithmetics ends up with such result.
I would recommend to look at the following videos:
- Introduction to RSA : Great pratical explanation from Eddie Woo
- Public key cryptography : Video from "the Art of the Problem"
- The Music of the Primes : Book by Marcus du Sautoy regarding Riemann's hypothesis.
- Udemy course about Number Theory and Cryptography
The following content is pretty math-heavy:
- Wikipedia page regarding Euler's theorem
- Brilliant page regarding Modular Arithmetic
- Using https://reactjs.org for front-end component and state management
- This project was bootstrapped with Create React App.
- Using JSBI for management of BigInt, necessary for mathematical computations but impossible to transpile for backward compatibility.
- Using https://fontflipper.com/upload to help choosing the fonts
- Using Unsplash to find background picture