1 / 11
文档名称:

M2 基于DES加密的TCP聊天程序设计与实现-课件PPT(讲稿).ppt

格式:ppt   页数:11页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

M2 基于DES加密的TCP聊天程序设计与实现-课件PPT(讲稿).ppt

上传人:huiwei2002 2016/3/29 文件大小:0 KB

下载得到文件列表

M2 基于DES加密的TCP聊天程序设计与实现-课件PPT(讲稿).ppt

相关文档

文档介绍

文档介绍:2017-1-3 中原工学院计算机学院 1 ???????????? DES ??? TCP ??????????????? sunfeixian@ 2017-1-3 中原工学院计算机学院 2 ????????????? DES ???????? DES ????????????????????????? Socket ??????????????? 2017-1-3 中原工学院计算机学院 3 DES ?????C?????<< ??>> ??& ???| ???^ ???? 2017-1-3 中原工学院计算机学院 4 unsigned char a=173; 10101101 unsigned char b=203; 11001011 unsigned char c=a&b;10001001 2017-1-3 中原工学院计算机学院 5 ? unsigned int a=8;0000000000001000 ????? 1 a=a^(1<<31); ? unsigned char a=173; 10101101, 输出二进制数每一位 for(i =0;i<8;i++) { b=(a>>i)&1 printf( “%d ”,b)} 2017-1-3 中原工学院计算机学院 6 DES ????????? 64 ??? bool plaintext[64]; bool ciphertext[64]; 如:明文= ’ hello world ’ ASCII: 104 101 108 108 111 32 119 111 m=m1m2 ? m64= 01101000 01100101 01101100 01101100 01101111 00100000 01110111 01101111 Plaintext[0]=0, Plaintext[1]=1, Plaintext[2]=1 Plaintext[3]=0, Plaintext[4]=1, Plaintext[5]=0 ……. Plaintext[63]=1 2017-1-3 中原工学院计算机学院 7 ???????? DES(bool out[64], bool in[64],bool SubKey[16][48]) { static bool M[64], tmp[32], * Li=&M[0], * Ri =&M[32]; memcpy(M , in, 64); Transform_IP(M ); // ?M? IP?? for(int i=0; i<15; ++i) { memcpy(tmp , Ri , 32); F_func(Ri , SubKey[i]);//f ?? Xor32(Ri, Li);//Ri ?????? R i?1 memcpy(Li , tmp , 32);//Li ?????? L i?1 } memcpy(tmp , Ri , 32); F_func(Ri , SubKey[i ]); Xor(Li,Ri ); memcpy(Ri , tmp , 32); Transform_IPR(M ); // ?M? IP??? memcpy(out,M , 64); } 2017-1-3 中原工学院计算机学院 8 void F_func(bool In[32], const bool Ki[48]) { static bool MR[48]; Transform_E(MR , In);//E ???? Xor48(MR, Ki , 48); S_func(In , MR);//S ??? Transform_P(In );//P ??} 2017-1-3 中原工学院计算机学院 9 S_func(S ?????) void S_func(bool Out[32], const bool In[48]) { int i,j,k ; for(i =0; i<8; i++) { j = (In[0]<<1) + In[5]; k = (In[1]<<3) + (In[2]<<2) + (In[3]<<1) + In[4]; Out[0]=S_Box[i][j][k]&1; Out[1]=( S_Box[i][j][k ]>>1)&1; Out[2]=( S_Box[i][j][k ]>>2)&1; Out[3]=( S_Box[i][j][k ]>>3)&1; In+=6;Out+=4; } } 2017-1-3 中原工学院计算机学院 10 const static char S_Box[8][4