资源简介
DES对于文件的加密解密,采用CBC-DES模式编写。可联系maibox_krj@163.com获取。

代码片段和文件信息
#include “bit.h“
//获取指定地址指定位信息(0/1)
int get_bit(unsigned char * input int pos)
{
//单字节最高位为第0位
unsigned char mask i bit;
for(bit = pos % 8 mask = 0X80 i = 0; i < bit; i++){
mask >>= 1;
}
return ( ( (mask & input[pos/8]) == mask ) ? 1 : 0 );
}
//设置指定地址指定位信息(value = 0/1)
void set_bit(unsigned char * input int pos int value)
{
unsigned char mask i bit;
for(bit = pos % 8 mask = 0X80 i = 0; i < bit; i++){
mask >>= 1;
}
(value) ? (input[pos/8] |= mask) : (input[pos/8] &= (~mask));
}
//异或操作output存储异或后的结果,size为需要异或的位数
void xor_bit(unsigned char * input1 unsigned char * input2 unsigned char * output int size)
{
int i;
for(i = 0; i < size; i++){
if(get_bit(input1 i) == get_bit(input2 i)){
set_bit(output i 0);//相同为0
}
else{
set_bit(output i 1);//不同为1
}
}
}
//循环左移,size为总循环的长度,num为循环左移的位数
void rol_bit(unsigned char * input int size int num)
{
//注意:低字节为左,高字节为右(与字符存储方式对应)
//如果低字节为右,高字节为做,写法相似
int left_bit = 0 loop_bit = 0 i = 0 j = 0;
if(size > 0){
for(i = 0; i < num; i++){//循环左移一位,共num次
for(j = 0; j <= (size-1)/8; j++){//多字节操作
left_bit = get_bit(&input[j] 0);//获取最高位
if(j == 0){
//如果是低字节,则其第一位,是左边溢出的,需要保存并在最终放到高字节右边最后一位
loop_bit = left_bit;
}
else{
//不是则直接将本字节第一位,设置到上一字节(低字节也是左边的字节)最后一位
set_bit(&input[j-1] 7 left_bit);
}
input[j] <<= 1;
}
//把左边移出的一位,移入最右边一位(即循环左移)
set_bit(input size-1 loop_bit);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-07-25 21:29 code\
文件 1921 2017-07-25 21:25 code\bit.cpp
文件 511 2017-07-25 21:25 code\bit.h
文件 128 2017-07-25 21:25 code\ciphertext.txt
文件 16919 2017-07-25 21:25 code\des
文件 9557 2017-07-25 21:32 code\des.cpp
文件 480 2017-07-25 21:25 code\des.h
文件 32 2017-07-25 21:25 code\key.txt
文件 630 2017-07-25 21:25 code\main.cpp
文件 129 2017-07-25 21:25 code\new
文件 128 2017-07-25 21:25 code\newPlaintext.txt
文件 125 2017-07-25 21:25 code\plaintext.txt
- 上一篇:红蓝坐标轴Excel图表
- 下一篇:LM324 电池电量检测
相关资源
- Remote Desktop Organizer v1.4.7 支持win10
- 3des加解密_C 实现
- RSA AES DES ECC加密算法源码
- 密码学课程设计:DES加密解密算法的
- 提供几个加密算法的源码
- DES IP置换IP逆置换
- DES的C 源码
- Design of Analog CMOS Integrated Circuits 拉扎
- codesys编程手册中文版
- System Design Interview - An Insider’s Guide
- Grokking the System Design Interview
- 翻译的美国大学经典参考书,Roland
- 认识界面以及PCB设计整体要求
- The Research on Smart Drill-in Fluid Design
- 埃塞俄比亚东北部Dessie转诊医院的糖
- Altium designer超全元件库+封装库部分
- dive into design patterns(Alexander Shvets)
- Antenna Theory Analysis and Design.3rd Edition
- FMEDesktop2019特别版forMacv2019.0.0.0.19181苹
- LANDesk 管理解决方案和采用英特尔:r
- Mentor Graphics Expedition Enterprise v7.9.5.r
- PowerDesigner16.6 破解补丁
- Altium Designer实战攻略与高速PCB设计P
- 复旦dc综合工具教程
- lotus domino notes(包括client administrato
- Type-c 接口封装,24引脚,Altium Design
- Behavior Designer 1.6.3(u2018.3.0).unitypa
- Codesys变成入门手册
- xenapp 7.6 xendesktop 7.6 企業版55永久用戶
-
Databa
se Reliability Engineering Designing
评论
共有 条评论