DES算法用C++实现的源代码
DES算法用C++实现的源代码
用C++实现的源代码
#include "memory.h"
#include "stdio.h"
enum {encrypt,decrypt};//ENCRYPT:加密,DECRYPT:解密
void des_run(char out[8],char in[8],bool type=encrypt);
//设置密钥
void des_setkey(const char key[8]);
static void f_func(bool in[32],const bool ki[48]);//f函数
static void s_func(bool out[32],const bool in[48]);//s盒代替
//变换
static void transform(bool *out, bool *in, const char *table, int len);
static void xor(bool *ina, const bool *inb, int len);//异或
static void rotatel(bool *in, int len, int loop);//循环左移
//字节组转换成位组
static void bytetobit(bool *out,const char *in, int bits);
//位组转换成字节组
static void bittobyte(char *out, const bool *in, int bits);
//置换IP表
conststatic char
ip_table[64]={58,50,42,34,26,18,10,2,60,52,44,36,28,20,12,4,62,54,46,38,30,22,14,6,64,56,48,40,32,24,16,8,57,49,41,33,25,17,9,1,59,51,43,35,27,19,11,3,61,53,45,37,29,21,13,5,63,55,47,39,31,23,15,7};
//逆置换IP-1表
const static char
ipr_table[64]={40,8,48,16,56,24,64,32,39,7,47,15,55,23,63,31,38,6,46,14,54,22,62,30,37,5,45,13,53,21,61,29,36,4,44,12,52,20,60,28,35,3,43,11, 51,19,59,27,34,2,42,10,50,18,58,26,33,1,41,9,49,17,57,25};
//E 位选择表
static const char e_table[48]={32,1, 2, 3, 4, 5,4, 5, 6, 7, 8, 9,8, 9,
10,11,12,13,12,13,14,15,16,17,16,17,18,19,20,21,20,21,22,23,24,25,24,25,26,27,28,29,28,29,30,31,32,1};
//P换位表
const static char
p_table[32]={16,7,20,21,29,12,28,17,1,15,23,26,5,18,31,10,2,8,24,14,32,27,3,9,19,13,30,6,22,11,4,25};
//pc1选位表
const static char pc1_table[56]={
57,49,41,33,25,17,9,1,
58,50,42,34,26,18,10,2,
59,51,43,35,27,19,11,3,
60,52,44,36,63,55,47,39,
31,23,15,7,62,54,46,38,
30,22,14,6,61,53,45,37,
29,21,13,5,28,20,12,4
DES算法的C++编写实现 下面是我将DES加密解密算法用C++编写并保存为des.h头文件...p ] 点这打开des.h文件链接(本来想C#风格“插入代码”的,结果字符数有限制)...
DES算法源代码-JAVA_IT/计算机_专业资料。DES 算法提供 CBC, OFB, CFB, ECB 四种模式,MAC 是基于 ECB 实现的。 一、数据补位 DES 数据加解密就是将数据按照...
DES算法及其VC源代码_工学_高等教育_教育专区。DES算法及其VC源代码DES 算法及其在 VC++6.0 下的实现 (上 ) 上 摘要: 本文介绍了一种国际上通用的加密算法...
加密解密算法的C++实现 22页 免费 DES加密解密的C++源程序 10页 免费 DES源代码...C16 D16 PC-2 K16 图 4 DES 子密钥生成流程图 图 4 给出了子密钥产生...
一、实验目的 在本实验中,用 VC/ C/C++/Java 实现DES的加解密算法。完成实验...图4 添加控件后的界面 3.编写源代码(1)DES 算法详述(主要描述算法流程) DES...
喜欢此文档的还喜欢 DES源代码 10页 免费 DES算法的C语言代码及实现 16页 免费 DES源代码 9页 免费 DES算法C++实现 3页 2财富值 DES代码 6页 2财富值...
DES 加密算法的 C++实现 实验一 1、实验题目利用 C/C++编程实现 DES 加密算法...即可完成 DES 的加密,代码的主要几个函数如下: //Byte转为Bit ByteToBit(...
C++实现 姓名: 学号: 学院: 2010 年 10 月 一、 DES 算法的实现 1.DES ...解密过程(同时生成明文外部文档) 三、 源代码 #include "stdafx.h" #include...
[j]-1]; } } void DES(char Out[8],char In[8],bool MS)//加密核心...DES算法的C语言代码及实... 16页 免费 DES算法实现C语言版 暂无评价 6页 1...
网络安全DES算法java实现源代码_计算机软件及应用_IT/计算机_专业资料。java实现DES算法源代码public class DesUtil { byte[] bytekey; public DesUtil(String strKey...
热门文档