Live demo here
This is a web-based encryption proposal developed for "Introduction to Cryptography" (Universidad Nacional de Colombia). Below you will find a walkthrough and a brief explanation of the project. The front-end was built using Bootstrap
and Django
.
- Easily encrypt and decrypt plain text, the user can provide a key; otherwise the app will provide a random one.
- Perform cryptoanalysis and attack and retrieve information from encrypted texts.
- Encrypt and decrypt images using the Hill Image-Encryption method
- Hill Image Encryption
- Shift cipher
- Multiplicative Cipher
- Transposition Cipher
- Vigenere cipher
- Affine cipher
- Substitution cipher
The Hill cipher algorithm is a symmetric key algorithm which means that we can get the decryption key out of the encryption one easily. In this case, we use an Involutory Key Matrix, the reason bethind this is that the inverse of an involutory matrix is itself, making the decryption methods easier.
The result of applying Hill Image Encryption are the following:
Original image | Encrypted image | Encryption key | Decrypted image |
Original image | Encrypted image | Encryption key | Decrypted image |
The Shift cipher (also known as Caesar cipher) works by using the modulo operator to encrypt and decrypt messages. The Shift Cipher has a key
The Multiplicative cipher works by multiplying each letter's value by
Vigenere Cipher uses polyalphabetic substitution scheme, this means it uses multiple substitutions over a single text. In the Shift Cipher, all the letters are shifted by the same amount
To decript, the decryption function is applied:
The Affine cipher works by using the following encryption function:
-
$a$ and$b$ must be relative primes to 26. -
$b$ is smaller than$a$ . The affine cipher is a reinforcement to the multiplicative cipher mentioned earlier.
The decryption function is defined as:
For version 2.0, bugs from the first release were fixed and the block cipher cryptosystems module was added, among which the following are shown below
The Gamma-Pentagonal cryptographic system has the property of probabilistic security since it is associated with a difficult problem of number theory.
More precisely, the problem we are dealing with consists in determining the number of ways in which an integer can be written as the sum of three polygonal numbers. It is recalled that polygonal numbers are those that can be described as a polygonal arrangement of points, for example, triangular numbers, squares, pentagonal, etc.
The difficult problem is to determine in how many ways a positive integer can be written as a sum of at least three square numbers. The above problem can be seen as finding how many admissible trajectories such as the ones we will illustrate later, connect the origin with a point in the usual plane. Then the point is related to a letter. The set-up process is as follows:
- The user must provide the
origin
coordinates, apermutation
and theclear text
. The origin and the permutation must remain secret. - A matrix of 10 columns is created, each of which contains the complete alphabet (26 letters). Then the order of each column is shifted, the magnitude of the displacement is determined by the respective number in the initial permutation.
- At the same time, the following equivalence classes are created:
$$\overline{x} := [ (a,b): a+b=x ] $$ Then,$d(\bar x)$ is defined as the sum of the incoming arrows for each point in the class. - Finally, the value of each
$a_{i,j}$ in the matrix is shifted by$d(\overline{(i,j)})$ units.
After this, the system is ready to encrypt, for each letter of the clear text, the letter's position
As an example, a resulting matrix using
A graph generated with (0,0) as the origin point is shown bellow
To Decript, the user must provide the origin coordenates, the permutation and the ciphered coordenates. After doing the set-up, the coordinates are translated into letters, returning the original clear text. Since the keys in each alphabet can be used with the same probability when constructing ciphertexts then we can infer that the gamma-pentagonal system is unbreakable.
For version 3.0, bugs from the second release were fixed, such as Hill-Image encryption bugs. Encryption methods were optimized. Public Key cryptosystems module was added, among which the following are shown below:
- RSA Encryption
- Rabin cipher
- Elgamal Cipher (DLP)
- Elgamal Cipher (Eliptic curve: EC255519)
- Digital signature Authenticator (Eliptic curve: SECP256k1)
(Back to top)
As a general requirement, is is mandatory to have Python
and Bootstrap 4
installed.
After cloning this repository and entering the directory, follow this steps:
First, enter the criptosite/
folder and execute
pip install -r requirements.txt
After that, execute
python main.py runserver
Finally, open any web browser and traverse to
127.0.0.1:8000/
to view the app.
This repository was developed by Juan Pablo Urrutia, Oscar Ordoñez, Raul Peña and Paola Gallegos. Any questions, please don't hesitate to reach out.