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