1、 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10,
2、 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb ; temp0=getSBoxValue(temp0); t
3、emp1=getSBoxValue(temp1); temp2=getSBoxValue(temp2); temp3=getSBoxValue(temp3); temp0 = temp0 Rconi/Nk; else if (Nk 6 & i % Nk = 4) RoundKeyi*4+0 = RoundKey(i-Nk)*4+0 temp0; RoundKeyi*4+1 = RoundKey(i-Nk)*4+1 temp1; RoundKeyi*4+2 = RoundKey(i-Nk)*4+2 temp2; RoundKeyi*4+3 = RoundKey(i-Nk)*4+3 temp3;
4、i+;void AddRoundKey(int round) int i,j; for(i=0;i4;i+) for(j=0;j0;round-) InvShiftRows(); InvSubBytes(); AddRoundKey(round); InvMixColumns(); AddRoundKey(0); outi*4+j=stateji;void SubBytes() stateij = getSBoxValue(stateij);void ShiftRows() void Cipher() for(round=1;roundNr;round+) SubBytes(); ShiftR
5、ows(); MixColumns();char *encrypt(char *str, char *key) int i,j,Nl; double len; char *newstr; Nk = Nc / 32; Nr = Nk + 6; len= strlen(str); Nl = (int)ceil(len / 16); /printf(Nl:%dn, Nl); newstr = (char *)malloc(Nl*32); memset(newstr,0,sizeof(newstr);Nl;Nk*4; Keyj=keyj; inj=stri*16+j; KeyExpansion();
6、Cipher(); memcpy(&newstri*32, out, 32); return newstr;char *decrypt(char *str, char *key) int i,j,len,Nl; newstr = (char *)malloc(16*Nl); InvCipher(); memcpy(&int main() char str_1128;/存明文 char str_2128;/存加密密钥 char str_3128;/存解密密钥 char *str; char *str2; printf(请输入明文:n); scanf(%s,str_1);请输入加密密钥:,str_2); str= encrypt(str_1, str_2);进行加密后:%snn, str);请输入解密密钥:,str_3); str2 = decrypt(str,str_3);进行解密后:%sn, str2); getch(); return 0;
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2