Un package Python simple à utiliser pour implémenter et expérimenter le célèbre algorithme DES de cryptage. Il implémente à la fois classique (paramètres par défaut de la description du manuel de DES) et DES non classiques. Consultez l'application DES pour une implémentation très spécifique démontrant l'effet d'avalanche et les clés faibles à l'aide du package.
Il y a pas mal de packages DES pour Python, mais aucun d'entre eux n'offre une telle flexibilité pour implémenter une version non classique du DES. Ce package vise spécifiquement à expérimenter les différents hyperparamtres qui peuvent être modifiés lors de la mise en œuvre du DES.
help(<function_name>) dans l'interpréteur Python.Bonus : Ce package peut être un économie de vie pour le CSE 537 - le cours de sécurité du réseau enseigné à l'IIT (BHU).
* L'ajustement de ces éléments peut nécessiter de modifier le code source à partir de la version actuelle
Exécutez la commande suivante dans votre terminal / commande de commande-
$ pip install DESfiddle
Remarque : Si vous n'avez pas installé
pip, suivez ces étapes.
# Importing
import DESfiddle.utils as dfu
# Usage
permutation_arr = dfu.generate_permutation(64)
# Importing
from DESfiddle.utils import *
# or just specify the function name you wanna import
# Usage
permutation_arr = generate_permutation(64)
from DESfiddle.utils import *
# Inputs in binary setting
plaintext = "0101010101010101010101010101010101010101010101010101010101010101"
key = "1111111111111111111111111111111100000000000000000000000000000000"
# Settings
nor = 16
halfwidth = 32
hamming_dist = 1
# Hamming the plaintext in binary mode
ref_pt_arr = preprocess_plaintext(plaintext, halfwidth)
pt_arr = preprocess_plaintext(plaintext, halfwidth, hamming_dist)
key = preprocess_key(key, halfwidth)
rkb,rkh = generate_round_keys(key,nor, halfwidth)
ref_ciphertext, ref_round_ciphertexts = encrypt(ref_pt_arr, rkb, nor, halfwidth)
_, round_ciphertexts = encrypt(pt_arr, rkb, nor, halfwidth)
diff = calc_diff(ref_round_ciphertexts, round_ciphertexts)
# Hamming the key in binary mode
pt_arr = preprocess_plaintext(plaintext, halfwidth)
ref_key = preprocess_key(key,halfwidth)
key = preprocess_key(key, halfwidth, hamming_dist)
ref_rkb, ref_rkh = generate_round_keys(ref_key, nor, halfwidth)
rkb,_ = generate_round_keys(key, nor, halfwidth)
ref_ciphertext, ref_round_ciphertexts = encrypt(pt_arr, ref_rkb, nor, halfwidth)
_, round_ciphertexts = encrypt(pt_arr, rkb, nor, halfwidth)
diff = calc_diff(ref_round_ciphertexts, round_ciphertexts)
from DESfiddle.utils import *
# Inputs in ASCII setting
plaintext = "This is so cool"
key = "Yesss"
# Settings
nor = 16
halfwidth = 32
hamming_dist = 1
# Preprocessing when input in ASCII
plaintext = txt_to_hex(plaintext)
plaintext = hex_to_bin(plaintext)
key = txt_to_hex(key)
key = hex_to_bin(key)
# Hamming the plaintext in binary mode
ref_pt_arr = preprocess_plaintext(plaintext, halfwidth)
pt_arr = preprocess_plaintext(plaintext, halfwidth, hamming_dist)
key = preprocess_key(key, halfwidth)
rkb,rkh = generate_round_keys(key,nor, halfwidth)
ref_ciphertext, ref_round_ciphertexts = encrypt(ref_pt_arr, rkb, nor, halfwidth)
_, round_ciphertexts = encrypt(pt_arr, rkb, nor, halfwidth)
diff = calc_diff(ref_round_ciphertexts, round_ciphertexts)
# Hamming the key in binary mode
pt_arr = preprocess_plaintext(plaintext, halfwidth)
ref_key = preprocess_key(key,halfwidth)
key = preprocess_key(key, halfwidth, hamming_dist)
ref_rkb, ref_rkh = generate_round_keys(ref_key, nor, halfwidth)
rkb,_ = generate_round_keys(key, nor, halfwidth)
ref_ciphertext, ref_round_ciphertexts = encrypt(pt_arr, ref_rkb, nor, halfwidth)
_, round_ciphertexts = encrypt(pt_arr, rkb, nor, halfwidth)
diff = calc_diff(ref_round_ciphertexts, round_ciphertexts)
Merci d'avoir pris le temps de contribuer!
Ce qui suit est un ensemble de directives pour contribuer à Desfiddle. Ce ne sont que des directives, pas des règles, alors utilisez votre meilleur jugement et n'hésitez pas à proposer des modifications à ce document dans une demande de traction.
Desfiddle est construit sur Python. Donc, si vous êtes nouveau à Python, veuillez vous rendre sur ce grand site Web.
Assurez-vous que le bogue n'a pas déjà été signalé en recherchant GitHub sous des problèmes. Si vous n'êtes pas en mesure de trouver un problème ouvert abordant le bogue, ouvrez un nouveau problème.
Des informations détaillées sont très utiles pour comprendre un problème, par exemple
Les demandes de traction sont toujours les bienvenues.
python -m unittest pour tester votre code avant de vous git commit .Suit la syntaxe vm.mp en premier est majeure et signifie non pas de changements compatibles en arrière. Le deuxième est mineur et signifie des changements compatibles en arrière. Le troisième est le patch et signifie de petits changements compatibles vers l'arrière.
Le lieu manuel de source de vérité pour la version est sur setup.py