Programme de chiffrement et déchiffrement affine d'un message en python3.

Overview

Chiffrement Affine En Python3

Programme de chiffrement et déchiffrement affine d'un message en python3.

Explication du chiffrement affine avec complexité O(n2)

  1. D’abord on donne une liste d’alphabet en minuscule et une liste d’alphabet en majuscule.

  2. On parcourt tout l’alphabet et on append l’alphabet en minuscule et l’alphabet en majuscule à chaque parcourt.

  3. On crée une fonction qui retourne le pgcd de deux nombres a et b, qui change la position de a et b à chaque parcourt et effectue le modulo de a et b.

  4. Ensuite on a une fonction de chiffrementAffine qui prend en paramètre a, b et L qui servira plus tard pour le chiffrement de notre message, au départ on testera si la lettre est une majuscule ou une minuscule après on cherchera l’indice de la lettre qu’on utilisera en appliquant la formule Y=(ax+b) mod 26 ou y est l’indice de la lettre chiffre sinon si la lettre n’est pas dans l’alphabet on (symbole) on la renverra.

  5. Après on a deux fonctions pour calculer l’inverse d’un nombre a, la 1ere n’a pas était vu en cours mais elle nécessite moins d’opérations que celle vu en cours et pour cela nous l’avons pris mais c ne change pas grande chose puisque la complexité reste la même pour les deux algorithmes. Pour le 1ere fonction elle prendra en paramètre a donnera son inverse modulaire 26 d’un nombre pour cela on initialise x à 0 et on utilise une boucle tant que a*x%26 n'est pas différent de 1, x prend la valeur de x + 1 et finit par retourner la valeur de x à la fin. Et pour la 2eme fonction d’Euclide on applique exactement la formule vue en cours pour l’algorithme d’Euclide étendu.

  6. Par la suite on a une fonction dechiffrementAfiine qui prend les mêmes paramètres de la fonction chiffrementAffine et qui fait la même chose que la fonction chiffrementAffine mais la seule différence est que y prend la valeur de (l’inverse de a)*(x-b) modulo 26. Au départ on testera si la lettre est une lettre majuscule ou minuscule après on récupéra l’indice de la lettre qu’on utilisera pour trouver l’indice de la lettre déchiffre en utilisant la formule évoque précédemment sinon si la lettre est un symbole on la renverra.

  7. On a deux fonctions l’une crypt et l’autre decrypt, l’une qui sert à crypter notre Jeux d’essais à l’aide de la fonction chiffrementAffine et l’autre sert à decrypter notre message, à l’aide de la fonction dechiffrementAffine ils vont toute les deux appeler les fonctions chiffrementAffine et dechiffrementAffine n fois avec n égale à la taille du message.

  8. Finalement on affiche les messages chiffrés et les messages déchiffrés.

Execution

python3 Chiffrement_Affine.py

Owner
Malik Makkes
Malik Makkes
This is a basic encryption and decryption program made in python.

A basic encryption and decryption program to visualize how the process of protecting data works.

Junaid Chaudhry 5 Nov 15, 2021
FileGuard - File crypter and packing utility

FILEGUARD FILEGUARD is a file crypter and packing utility. This project was orig

11 Nov 28, 2022
Certifi: Python SSL Certificates

(Python Distribution) A carefully curated collection of Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts.

Certifi 608 Jan 02, 2023
Vaulty - Encrypt/Decrypt with ChaCha20-Poly1305

Vaulty Encrypt/Decrypt with ChaCha20-Poly1305 Vaulty is an extremely lightweight encryption/decryption tool which uses ChaCha20-Poly1305 to provide 25

Chris Mason 1 Jul 04, 2022
Decrypting winrm traffic using password/ntlm hash

Decrypting winrm traffic using password/ntlm hash

Haoxi Tan 9 Jan 05, 2022
Salted Crypto Python library

Salted Crypto Python library. Allows to encrypt and decrypt files and directories using popular cryptographic algorithms with salty key(s).

7 Jul 18, 2022
A Python module to encrypt and decrypt data with AES-128 CFB mode.

cryptocfb A Python module to encrypt and decrypt data with AES-128 CFB mode. This module supports 8/64/128-bit CFB mode. It can encrypt and decrypt la

Quan Lin 2 Sep 23, 2022
This demo is an on-chain NFT auction using smart contracts on the Algorand blockchain.

Algorand Auction Demo This demo is an on-chain NFT auction using smart contracts on the Algorand blockchain. Usage The file auction/operations.py prov

1 Jan 27, 2022
Get the length of the Instagram encrypted password

instagram-weak-encryption Get the length of the Instagram encrypted password Introduction Instagram and Facebook encrypt the password submitted at log

Giuseppe Criscione 19 Dec 09, 2022
Simple BRender SDK KeyGen.

Super Simple BRender KeyGen Simple BRender SDK KeyGen. Info This is just a super simple keygen for the BRender SDK installer coded in python. All test

1 Jan 15, 2022
A Python Tool to encrypt all types of files using AES and XOR Algorithm.

DataShield This project intends to protect user’s data, it stores files in encrypted format in device provided the passcode and path of the file. AES

ADITYA SHINDE 4 Dec 20, 2021
DCAStack: an Automated Dollar Cost Averaging Bot for Your Crypto

Welcome to DCA Stack! An Automated Dollar Cost Averaging Bot For Your Crypto Web

0 Sep 03, 2022
Fully configurable automated python script to collect most visted pages based on google dork

Ranked pages collector Fully configurable automated python script to collect most visted pages based on google dork Usage This project is still under

Security Analyzer 9 Sep 10, 2022
A python-jvm wrapper for interacting with the Ergo blockchain.

ergpy A python-jvm wrapper for interacting with the Ergo blockchain. Usage Requires Java 8 or higher to be installed on system pip install JPype1 pip

mgpai 16 Oct 05, 2022
bitcoin-ticker is a E-ink ticker that shows usefull information about bitcoin

bitcoin-ticker bitcoin-ticker is a E-ink ticker that shows usefull information about bitcoin. Due to the limited refresh lifetime, new information is

32 Nov 09, 2022
Arithmos Cipher is a simple Cryptography that I created myself in Python

Arithmos Cipher is a simple Cryptography that I created myself in Python

LyQuid :3 3 Oct 19, 2022
En- and decrypting text-messages by creating a key with of the fibonacci-sequence

En- and decrypting text-messages by creating a key with of the fibonacci-sequence. This key helps to create mathematical functions, whose zeros should generates the encrypted message.

Pulsar 1 Feb 05, 2022
基于python的一款 加解密工具

基于python的一款 加解密工具 加密: SHA序列: sha1 , sha2 , sha224 , sha256 , sha384 , sha512 , sha512-256 , sha3-224 , sha3-256 , sha3-384 , sha3-512 MD序列: md4 , md5

3 May 05, 2022
Stai Beta Of Staiking Chain - Food, Water And Electricity - Worldwide

Stai Beta Of Staiking Chain - Food, Water And Electricity - Worldwide

STATION-I 2 Feb 05, 2022
Zero-dependency Cryptography Python Module with a self made method

TesohhCrypt TesohhCrypt is a zero-dependency Cryptography Python Module, with a method that i made. (likely someone already made a similar one, but i

Simone Tesini 1 Oct 26, 2021