128位AES加密算法C语言实现

上传者: kandy_000 | 上传时间: 2021-10-10 17:31:05 | 文件大小: 60KB | 文件类型: -
用C语言实现的128位AES加密算法,可以运行在JAVA的JNI 中AIS加密算法c语言实现代码 nt cnt for(ent =0: cnt< 8: cnt++) BvtcToBit(*(ch+cnt), bit+(ent<<3)) return /将二进制位串转为长度为8的字符串水 int Bit64ToChar8 (ElemType bitL64, ElemType ch18) int cnt memset(ch, 0, 8) for(ent-0: cnt<8: cnt++i BitToByte(bit+(cnt<<3), ch+cnt) return 0 /*生成子密钥 int DES Make Subkeys(ElemType key _64, ElemType subkeys [16][48]) ElemType temp 56 int cnt DES PCI Transform(key,temp):/*PCI置换* for(cnt=0;cnt<16;cnt+-){*16轮跌代,产生16个子密钥米 DES ROL(tenp, MOVE TIMES[cnt]);循坏左移* DES PC2 Transform(temp, subkeys cnt]);/PC2置换,产生子密钥体 return o /*密钥置換1*/ int DES PCI Transform(ElemType key [64, ElemType tempts[56])t int cnt for(cnt=0: cnt( 56 cnt++) )empts[cnt]= key[ Ilant] r巳turn /*密钥置換2* int DES PC2 Transform(Elem Type key [56], ElemType tempts[48])i t cnt for(ent =0: cnt< 48: cnt+)I )pbts [cnt]= key [PC 2[cnt]] return /*循环左移*/ int DES ROL (Elem Type data[56], int time)t Elem l'ype temp _56 /*保存将要循环栘动到右边的位* memcpy(temp, data, time) memcpy(temg-time, data+28, time) /*前28位移动 (data-28-time, temp, time) /*后28位移动* memcpy(data 28, data+28+time, 28-time memcpy (data-56-time, temp+time, time) return o /*P置换*/ int DES IP) Iransform(Elemlype data[64)[ ElemType temp _64]: for(cnt templet- datalIP Tablelcnt」」 memcpy(data, temp, 64) return o 第3页 AIS加密算法c语言实现代码 /*IP逆置換* int DES IP 1 Transform(ElemType data[64)( int cnt ElemType temp _64 for(cnt =0: cnt 64: cnt+-)i templet」- dataLIP1 Tablelcrt]」 memcpy(data, temp, 64) return o /*扩展置换*/ int DES E Transform(ElemType data[48])( Int cn ElemType temp48」 for(ent-0: cnt 48: cnt-) temp lent= datale Tablelent memcpy( data, temp, 48 return o P置换 int DES P Transform(ElemType data[32])( t ElemType temp_32] for(ent =0; cnt 32; cnt+-) temp ent-datalP Tablel 11 me.mcpy(data, temp, 32) return 0 /水异或* int DES XOR(Elem Type R[48, Elem Type L[48], int count)I int cnt for(cnt-0: cnt< count: cnt++)i RIant]= lent] return 0 /*S盒置换*/ int DES SBOX (Elem Type data[48]) int cnt int line, row, output int curl, cur for(en

文件下载

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明