基于DES结构ECB模式的加密算法设计
项目介绍
The block length is 16
The key length is 8
The number of rounds is 4 (4 encryption + 4 decryption)
ECB mod设计:
message file 应包含随机英文字母,我们将其视为原始 message。我的块的长度是16,我们用8位二进制来表示每个字母,所以每个块我们处理2个英文字母。
为了处理消息文件中的奇数个数的英文字母,在程序中输入消息文件时,我将输入的字母加倍以使英文字母数量变为偶数,例如:
如果消息文件的内容是“AVC”,我们就让它变成“AVCAVC”,当我们将内容输出到输出文件时,我们可以将其除以2。另外,当我们检查密文文件时,长度也会加倍,攻击者因此无法知道原始消息的长度。
ECB模式的设计
加密算法设计
解密算法设计
The Initial Permutation Design
密钥生成算法设计
密钥生成算法设计如图所示:
The f design
雪崩效应的实现
字节的转换是基于ASCII码实现的,因此:
Set the message file content: CC (0100001101000011)
Set the key file content: 11001010
Do the encryption we get:
Next, set the message file content: CS (0100001101010011)
we can see that the input message only has one-bit change (12th ) but for the output ciphertext, there are 5 bits change (4th , 5th ,6th ,7th , 13th ).
因此,成功实现了雪崩效应。
如果你发现你的雪崩效应没有实现,那么请尝试修改你的算法。
Python程序已被上传到我的资源中。