[源码和文档分享]基于C++的分组密码加解密实现
1 设计实现
程序完成课程设计所有必做与选做的要求,包含的函数如下:
// S 盒置换BlockType SBox_Encode(BlockType x);// S 盒逆变换BlockType SBox_Decode(BlockType x);// P 盒置换BlockType PBox_Encode(BlockType x);// P 盒逆变换BlockType PBox_Decode(BlockType x);// 输出显示一个 16 位二进制数void OutPut_Bin(BlockType p);// 输出显示一个密钥void OutPut_Key(KeyType key);// 分组加密函数void BlockEncryption(BlockType PlainText, BlockType&CipherText, KeyType Key);// 分组解密函数void BlockDecryption(BlockType &PlainText, BlockTypeCipherText, KeyType Key);// 生成指定密钥void Key_Engine();// 随机生成密钥void Key_Random();// 文件加密int FileEncryption(char *PlainFile,char *CipherFile,KeyType Key);// 文件解密int FileDecryption(char *PlainFile,char *CipherFile,KeyType Key);// 加密函数的运行速度unsigned long EncryptionTime(unsigned long Times);// 线性密码分析BlockType LinearCryptanalysis(unsigned long T,BlockType Text[][2]);// 差分密码分析BlockType DiffCryptanalysis(unsigned long T,BlockType Text[][4]);// 测试分组加密与解密void TestBlockEncrypt();// 测试文件加密与解密void TestFileEncrypt();// 测试运行速度void TestEncryptionTime();// 测试线性密码分析void TestLinearCryptanalysis();// 测试差分密码分析void TestDiffCryptanalysis();// 测试线性分析函数成功时明密文对数void TestLinearSucceedTimes();// 测试差分分析函数成功时明密文对数void TestDiffSucceedTimes();// 暂停,按回车键继续void Wait();
测试程序只需打开生成的可执行文件,按提示操作即可。
运行截图如下:

任意输入一个小于 65536
参考文档和完整的文档和源码下载地址:
浙公网安备 33010602011771号