[源码和文档分享]基于C++的分组密码加解密实现

1 设计实现

程序完成课程设计所有必做与选做的要求,包含的函数如下:

 
  1. // S 盒置换
  2. BlockType SBox_Encode(BlockType x);
  3. // S 盒逆变换
  4. BlockType SBox_Decode(BlockType x);
  5. // P 盒置换
  6. BlockType PBox_Encode(BlockType x);
  7. // P 盒逆变换
  8. BlockType PBox_Decode(BlockType x);
  9. // 输出显示一个 16 位二进制数
  10. void OutPut_Bin(BlockType p);
  11. // 输出显示一个密钥
  12. void OutPut_Key(KeyType key);
  13. // 分组加密函数
  14. void BlockEncryption(BlockType PlainText, BlockType
  15. &CipherText, KeyType Key);
  16. // 分组解密函数
  17. void BlockDecryption(BlockType &PlainText, BlockType
  18. CipherText, KeyType Key);
  19. // 生成指定密钥
  20. void Key_Engine();
  21. // 随机生成密钥
  22. void Key_Random();
  23. // 文件加密
  24. int FileEncryption(char *PlainFile,char *CipherFile,KeyType Key);
  25. // 文件解密
  26. int FileDecryption(char *PlainFile,char *CipherFile,KeyType Key);
  27. // 加密函数的运行速度
  28. unsigned long EncryptionTime(unsigned long Times);
  29. // 线性密码分析
  30. BlockType LinearCryptanalysis(unsigned long T,BlockType Text[][2]);
  31. // 差分密码分析
  32. BlockType DiffCryptanalysis(unsigned long T,BlockType Text[][4]);
  33. // 测试分组加密与解密
  34. void TestBlockEncrypt();
  35. // 测试文件加密与解密
  36. void TestFileEncrypt();
  37. // 测试运行速度
  38. void TestEncryptionTime();
  39. // 测试线性密码分析
  40. void TestLinearCryptanalysis();
  41. // 测试差分密码分析
  42. void TestDiffCryptanalysis();
  43. // 测试线性分析函数成功时明密文对数
  44. void TestLinearSucceedTimes();
  45. // 测试差分分析函数成功时明密文对数
  46. void TestDiffSucceedTimes();
  47. // 暂停,按回车键继续
  48. void Wait();

测试程序只需打开生成的可执行文件,按提示操作即可。

运行截图如下:

任意输入一个小于 65536 


参考文档和完整的文档和源码下载地址:

https://www.write-bug.com/article/1306.html

猜你喜欢

转载自blog.csdn.net/demongwc/article/details/84850513
今日推荐