DESfiddle
1.0.0
一种易于使用Python软件包,用于实现和实验著名的DES加密算法。它实现了经典(来自DES的教科书描述中的默认设置)和非古典DES。查看DES应用程序,以显示使用包装的雪崩效果和弱键的非常具体的实现。
Python有很多DES软件包,但它们都没有提供如此高的灵活性来实现DES的非古典版本。该软件包的目的是针对实施DES时可以调整的不同超级参数进行试验。
help(<function_name>)即可。奖励:此软件包可以是IIT(BHU)教授的CSE 537-网络安全课程的救生。
*调整其中一些可能需要更改当前版本的源代码
在您的终端/命令提示中运行以下命令 -
$ pip install DESfiddle
注意:如果您没有安装
pip,请按照以下步骤操作。
# 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)
感谢您抽出宝贵的时间贡献!
以下是为Desfiddle做出贡献的一组准则。这些只是准则,而不是规则,因此请使用您的最佳判断,并随时在拉动请求中提出对本文档的更改。
Desfiddle建于Python上。因此,如果您是Python的新手,请前往这个很棒的网站。
通过在问题上搜索GitHub,请确保尚未报告该错误。如果您找不到解决该错误的空旷问题,请打开一个新问题。
详细信息对于了解问题非常有帮助,例如
始终欢迎拉动请求。
git commit之前运行python -m unittest以测试您的代码。遵循语法VM.MP首先是主要的,并不意味着向后兼容的更改。第二是次要的,意味着向后兼容的变化。第三是补丁,意味着小的向后兼容更改。
该版本的真相来源的手册位于setup.py