[源码和文档分享]基于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, BlockType

CipherText, 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 

6607861-f7a5566b8ba1c0b7.png

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

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值