#include #include #include #include #include int E[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 }; int Pc[32] = { 9,17,23,31,13,28,2,18,24,16,30,6,26,20,10,1,8,14,25,3,4,29,11,19,32,12,22,7,5,27,15,21 }; int PC1c[64] = { 8,16,24,56,52,44,36,57,7,15,23,55,51,43,35,58,6,14,22,54,50,42,34,59,5,13,21,53,49,41,33,60,4,12,20,28,48,40,32,61,3,11,19,27,47,39,31,62,2,10,18,26,46,38,30,63,1,9,17,25,45,37,29,64 }; int PCr[48] = { 14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32 }; int P[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 }; int S[8][4][16] = { {{14,4,13,1,2,15,11,8,3,10,6,12,5,9,0,7},{0,15,7,4,14,2,13,1,10,6,12,11,9,5,3,8},{4,1,14,8,13,6,2,11,15,12,9,7,3,10,5,0},{15,12,8,2,4,9,1,7,5,11,3,14,10,0,6,13}}\ ,{{15,1,8,14,6,11,3,4,9,7,2,13,12,0,5,10},{3,13,4,7,15,2,8,14,12,0,1,10,6,9,11,5},{0,14,7,11,10,4,13,1,5,8,12,6,9,3,2,15},{13,8,10,1,3,15,4,2,11,6,7,12,0,5,14,9}}\ ,{{10,0,9,14,6,3,15,5,1,13,12,7,11,4,2,8},{13,7,0,9,3,4,6,10,2,8,5,14,12,11,15,1},{13,6,4,9,8,15,3,0,11,1,2,12,5,10,14,7},{1,10,13,0,6,9,8,7,4,15,14,3,11,5,2,12}}\ ,{{7,13,14,3,0,6,9,10,1,2,8,5,11,12,4,15},{13,8,11,5,6,15,0,3,4,7,2,12,1,10,14,9},{10,6,9,0,12,11,7,13,15,1,3,14,5,2,8,4},{3,15,0,6,10,1,13,8,9,4,5,11,12,7,2,14}}\ ,{{2,12,4,1,7,10,11,6,8,5,3,15,13,0,14,9},{14,11,2,12,4,7,13,1,5,0,15,10,3,9,8,6},{4,2,1,11,10,13,7,8,15,9,12,5,6,3,0,14},{11,8,12,7,1,14,2,13,6,15,0,9,10,4,5,3}}\ ,{{12,1,10,15,9,2,6,8,0,13,3,4,14,7,5,11},{10,15,4,2,7,12,9,5,6,1,13,14,0,11,3,8},{9,14,15,5,2,8,12,3,7,0,4,10,1,13,11,6},{4,3,2,12,9,5,15,10,11,14,1,7,6,0,8,13}}\ ,{{4,11,2,14,15,0,8,13,3,12,9,7,5,10,6,1},{13,0,11,7,4,9,1,10,14,3,5,12,2,15,8,6},{1,4,11,13,12,3,7,14,10,15,6,8,0,5,9,2},{6,11,13,8,1,4,10,7,9,5,0,15,14,2,3,12}}\ ,{{13,2,8,4,6,15,11,1,10,9,3,14,5,0,12,7},{1,15,13,8,10,3,7,4,12,5,6,11,0,14,9,2},{7,11,4,1,9,12,14,2,0,6,10,13,15,3,5,8},{2,1,14,7,4,10,8,13,15,12,9,0,3,5,6,11}} }; int PC2c[56] = { 5,24,7,16,6,10,20,18,49,12,3,15,23,1,9,19,2,50,14,22,11,51,13,4,52,17,21,8,47,31,27,48,35,41,53,46,28,54,39,32,25,44,55,37,34,43,29,36,38,45,33,26,42,56,30,40 }; using namespace std; class hexbin//16进制的数转换为2进制的数 private: char a[26], count, i, j, e; int bin[16][4]; public: int c[64]; int* bina(int n) { count = 0; cout << "请输入16进制的数" << n << ":"; cin >> a; for (i = 0; a[i] != '\0'; i++)//每个字符对应相应的四位的二进制数 { switch (a[i]) { case'0': bin[i][0] = 0; bin[i][1] = 0; bin[i][2] = 0; bin[i][3] = 0; break; case'1': bin[i][0] = 0; bin[i][1] = 0; bin[i][2] = 0; bin[i][3] = 1; break; case '2': bin[i][0] = 0; bin[i][1] = 0; bin[i][2] = 1; bin[i][3] = 0; break; case '3': bin[i][0] = 0; bin[i][1] = 0; bin[i][2] = 1; bin[i][3] = 1; break; case '4': bin[i][0] = 0; bin[i][1] = 1; bin[i][2] = 0; bin[i][3] = 0; break; case '5': bin[i][0] = 0; bin[i][1] = 1; bin[i][2] = 0; bin[i][3] = 1; break; case '6': bin[i][0] = 0; bin[i][1] = 1; bin[i][2] = 1; bin[i][3] = 0; break; case '7': bin[i][0] = 0; bin[i][1] = 1; bin[i][2] = 1; bin[i][3] = 1; break; case '8': bin[i][0] = 1; bin[i][1] = 0; bin[i][2] = 0; bin[i][3] = 0; break; case '9': bin[i][0] = 1; bin[i][1] = 0; bin[i][2] = 0; bin[i][3] = 1; break; case 'A': bin[i][0] = 1; bin[i][1] = 0; bin[i][2] = 1; bin[i][3] = 0; break; case 'B': bin[i][0] = 1; bin[i][1] = 0; bin[i][2] = 1; bin[i][3] = 1; break; case 'C': bin[i][0] = 1; bin[i][1] = 1; bin[i][2] = 0; bin[i][3] = 0; break; case 'D': bin[i][0] = 1; bin[i][1] = 1; bin[i][2] = 0; bin[i][3] = 1; break; case 'E': bin[i][0] = 1; bin[i][1] = 1; bin[i][2] = 1; bin[i][3] = 0; break; case 'F': bin[i][0] = 1; bin[i][1] = 1; bin[i][2] = 1; bin[i][3] = 1; break; default: exit(-1); } count++; } e = 0; for (i = 0; i < 16; i++) //组合成一个数组 { for (j = 0; j < 4; j++) { c[e] = bin[i][j]; e++; } } memset(bin, 0, sizeof(int) * 64);//重置数组 memset(a, 0, sizeof(char) * 26); return c; } }; class kborn { private: int i, j, dd, d[56], C[20][28], D[20][28], a, CD[56], c, b, ee, cc, e, bin[8], bina[8], Bbin[8], CDC[56]; public: int ke[48]; int* ki(int qs, int n, int* CDC) { for (j = 0; j < 8; j++) //把值转换为二进制 { cc = qs / 2; bin[j] = qs % 2; qs = cc; if (qs == 0)//化到最后都会从2或1化到0 { for (dd = j + 1; dd < 8; dd++) //补位添0,成为8bit { bin[dd] = 0; } for (ee = 7; ee >= 0; ee--) { bina[7 - ee] = bin[ee]; } break; } } for (j = 0; j < 8; j++) { Bbin[j] = bina[j]; } CDC[0] = Bbin[0]; CDC[12] = Bbin[1]; CDC[21] = Bbin[2]; CDC[25] = Bbin[3]; CDC[29] = Bbin[4]; CDC[38] = Bbin[5]; CDC[41] = Bbin[6]; CDC[46] = Bbin[7]; for (i = 0; i < 28; i++)//划分成两段每段28bit { C[0][i] = CDC[i]; } for (i = 28; i < 56; i++) { D[0][i - 28] = CDC[i]; } for (i = 1; i <= n; i++)//循环移位 { if (i == 1 || i == 2)//移一位 { a = C[i - 1][0]; c = D[i - 1][0]; for (j = 0; j < 27; j++)//左循环移位一位 { C[i][j] = C[i - 1][j + 1]; D[i][j] = D[i - 1][j + 1]; } C[i][j] = a; D[i][j] = c; } else//移两位 { a = C[i - 1][0]; b = D[i - 1][0]; c = C[i - 1][1]; e = D[i - 1][1]; for (j = 0; j < 26; j++)//左循环移位两位 { C[i][j] = C[i - 1][j + 2]; D[i][j] = D[i - 1][j + 2]; } C[i][j] = a; D[i][j] = b; C[i][j + 1] = c; D[i][j + 1] = e; } } for (j = 0; j < 28; j++)//两个28bit合并为一段56比特 { CD[j] = C[i - 1][j]; } for (j = 28; j < 56; j++) { CD[j] = D[i - 1][j - 28]; } for (j = 0; j < 48; j++)//进行PC-2置换生成密钥 { ke[j] = CD[PCr[j] - 1]; } return ke; } }; int main() { int i, j, e, b, qs, m[64], L[20][32], K[20][48], EA[48], R[20][32], N, a[12][64], m1[64], M[64], CDC[64], L0[12][32], L3[12][32], R3[12][32], EL3[12][48], ELc[6][48], Ec[6][8][6], R3c[6][32], L0c[6][32], R3L0[6][32]; int d, CSS, js, hang, lie, dd, ee, jj, CD[56], CDc[56], Cc[6][32], Ccf[6][8][4], bin[6], bina[6], CS, CS1, binar[6], bin1[4], bin2[4], BIN[4], binary[8][64][6], Bbin[6], count[8][64]; int cc, C[8], B[48], ges, duis, binbin[8][4], Pt[32], T[32]; hexbin hbin; kborn kefe; cout << "请输入要输入明文的对数:"; cin >> duis; ges = 2 * duis; cout << "请输入明文:\n"; for (j = 0; j < ges; j++) //将16进制明文转换为二进制 { int* c = hbin.bina(j + 1); for (i = 0; i < 64; i++) { a[j][i] = c[i]; } } for (j = 0; j < ges; j++) { cout << "\n明文" << j + 1 << "是:"; for (i = 0; i < 64; i++) { cout << a[j][i]; if ((i + 1) == 32) cout << "\t"; } } for (i = 0; i < 64; i++)//把第一个明文复制给m1用于穷搜 { m1[i] = a[0][i]; } for (j = 0; j < ges; j++) //生成L0 { for (i = 0; i < 32; i++) { L0[j][i] = a[j][i]; } } memset(a, 0, sizeof(int) * 640); cout << endl; cout << "\n请输入密文:\n"; for (j = 0; j < ges; j++) //将16进制密文转换为二进制 { int* c = hbin.bina(j + 1); for (i = 0; i < 64; i++) { a[j][i] = c[i]; } } for (i = 0; i < 64; i++)//把第一个密文复制给m1用于穷搜 { M[i] = a[0][i]; } for (j = 0; j < ges; j++) //生成L3 { cout << "\n密文L" << j + 1 << "是:"; for (i = 0; i < 32; i++) { L3[j][i] = a[j][i]; cout << L3[j][i]; } cout << "\t密文R" << j + 1 << "是:"; for (i = 32; i < 64; i++) { R3[j][i - 32] = a[j][i]; cout << R3[j][i - 32]; } } cout << endl; for (i = 0; i < ges; i++) //进行E扩展置换 { cout << "\n进行E扩展置换后的值ER" << i + 1 << "是:"; for (j = 0; j < 48; j++) { EL3[i][j] = L3[i][E[j] - 1]; cout << EL3[i][j]; } } cout << endl; for (i = 0; i < ges;) //计算输入差分 { for (j = 0; j < 48; j++) { if (EL3[i][j] == EL3[i + 1][j]) ELc[i / 2][j] = 0; else ELc[i / 2][j] = 1; } i = i + 2; } for (i = 0; i < duis; i++) { cout << "\n第" << i + 1 << "对输入异或是:"; for (j = 0; j < 48; j++) { cout << ELc[i][j]; } } for (i = 0; i < duis; i++) //分组,每组6bit { for (j = 0; j < 48;) { for (e = 0; e < 6; e++) { Ec[i][j / 6][e] = ELc[i][e + j]; } j = j + 6; } } for (i = 0; i < ges;) //计算差分R3c { for (j = 0; j < 32; j++) { if (R3[i][j] == R3[i + 1][j]) R3c[i / 2][j] = 0; else R3c[i / 2][j] = 1; } i = i + 2; } for (i = 0; i < ges;) //计算差分L0c { for (j = 0; j < 32; j++) { if (L0[i][j] == L0[i + 1][j]) L0c[i / 2][j] = 0; else L0c[i / 2][j] = 1; } i = i + 2; } for (i = 0; i < duis; i++) //计算R3c和L0c的差分 { for (j = 0; j < 32; j++) { if (R3c[i][j] == L0c[i][j]) R3L0[i][j] = 0; else R3L0[i][j] = 1; } } for (i = 0; i < duis; i++) //P逆置换计算输出差分Cc { for (j = 0; j < 32; j++) { Cc[i][j] = R3L0[i][Pc[j] - 1]; } } cout << endl; for (i = 0; i < duis; i++) //P逆置换计算输出差分Cc { cout << "\n第" << i + 1 << "对输出异或是:"; for (j = 0; j < 32; j++) { cout << Cc[i][j]; } } for (i = 0; i < duis; i++) //分组,每组4bit { for (j = 0; j < 32;) { for (e = 0; e < 4; e++) { Ccf[i][j / 4][e] = Cc[i][e + j]; } j = j + 4; } } cout << endl; for (i = 0; i < duis; i++) //分段输出 输入异或 { cout << "\n第" << i + 1 << "对输入异或\n"; cout << 1 << "\t" << 2 << "\t" << 3 << "\t" << 4 << "\t" << 5 << "\t" << 6 << "\t" << 7 << "\t" << 8 << "\n"; for (j = 0; j < 8; j++) { for (e = 0; e < 6; e++) { cout << Ec[i][j][e]; } cout << "\t"; } } cout << endl; for (i = 0; i < duis; i++) //分段输出 输出异或 { cout << "\n第" << i + 1 << "对输出异或\n"; cout << 1 << "\t" << 2 << "\t" << 3 << "\t" << 4 << "\t" << 5 << "\t" << 6 << "\t" << 7 << "\t" << 8 << "\n"; for (j = 0; j < 8; j++) { for (e = 0; e < 4; e++) { cout << Ccf[i][j][e]; } cout << "\t"; } } cout << endl; memset(count, 0, sizeof(int) * 512); for (dd = 0; dd < 8; dd++) //依次按照S盒来检验找出合适的输入 { for (i = 0; i < 64; i++)//测试输入6bit,循环检验,找出符合IN()的输入 { CSS = i; memset(bina, 0, sizeof(int) * 6); memset(bin, 0, sizeof(int) * 6); memset(Bbin, 0, sizeof(int) * 6); for (j = 0; j < 6; j++) //把值转换为二进制 { b = CSS / 2; bin[j] = CSS % 2; CSS = b; if (CSS == 0)//化到最后都会从2或1化到0 { for (d = j + 1; d < 6; d++) //补位添0,成为6bit { bin[d] = 0; } for (e = 5; e >= 0; e--) { bina[5 - e] = bin[e]; } break; } } for (j = 0; j < 6; j++) { Bbin[j] = bina[j]; } memset(bin, 0, sizeof(int) * 6); hang = bina[0] * 2 + bina[5]; lie = bina[1] * 8 + bina[2] * 4 + bina[3] * 2 + bina[4]; CS = S[dd][hang][lie]; memset(bina, 0, sizeof(int) * 6); memset(bin, 0, sizeof(int) * 6); memset(bin1, 0, sizeof(int) * 4); for (j = 0; j < 4; j++) //把值转换为二进制 { b = CS / 2; bin[j] = CS % 2; CS = b; if (CS == 0)//化到最后都会从2或1化到0 { for (d = j + 1; d < 4; d++) //补位添0,成为4bit { bin[d] = 0; } for (e = 3; e >= 0; e--) { bina[3 - e] = bin[e]; } break; } } for (j = 0; j < 4; j++) { bin1[j] = bina[j]; } for (jj = 0; jj < duis; jj++)//检验不同对的值 { for (j = 0; j < 6; j++) //输入和输入异或两者异或 { if (Bbin[j] == Ec[jj][dd][j]) binar[j] = 0; else binar[j] = 1; } hang = binar[0] * 2 + binar[5]; lie = binar[1] * 8 + binar[2] * 4 + binar[3] * 2 + binar[4]; CS1 = S[dd][hang][lie]; memset(bin2, 0, sizeof(int) * 4); memset(bin, 0, sizeof(int) * 6); memset(bina, 0, sizeof(int) * 6); for (j = 0; j < 4; j++) //把值转换为二进制 { b = CS1 / 2; bin[j] = CS1 % 2; CS1 = b; if (CS1 == 0)//化到最后都会从2或1化到0 { for (d = j + 1; d < 4; d++) //补位添0,成为4bit { bin[d] = 0; } for (e = 3; e >= 0; e--) { bina[3 - e] = bin[e]; } break; } } for (j = 0; j < 4; j++) { bin2[j] = bina[j]; } memset(BIN, 0, sizeof(int) * 4); for (j = 0; j < 4; j++) { if (bin1[j] == bin2[j]) BIN[j] = 0; else BIN[j] = 1; } if ((BIN[0] == Ccf[jj][dd][0]) && (BIN[1] == Ccf[jj][dd][1]) && (BIN[2] == Ccf[jj][dd][2]) && (BIN[3] == Ccf[jj][dd][3]))//判断是不是满足IN的条件 { for (j = 0; j < 6; j++) { if (Bbin[j] == EL3[2 * jj][(dd * 6 + j)])//满足的话和Ei异或得到密钥 binary[dd][i][j] = 0; else binary[dd][i][j] = 1; } js = binary[dd][i][0] * 32 + binary[dd][i][1] * 16 + binary[dd][i][2] * 8 + binary[dd][i][3] * 4 + binary[dd][i][4] * 2 + binary[dd][i][5]; count[dd][js] = count[dd][js] + 1;//计数器,计算可能密钥出现的位置和次数 } } } } cout << endl; for (dd = 0; dd < 8; dd++) { cout << "\n\nS" << dd + 1 << ":\n"; for (i = 0; i < 64; i++) { cout << count[dd][i]; if ((i + 1) % 16 == 0) cout << "\n"; } } cout << endl << "得到的第3轮加密的48bit密钥为:\n"; for (dd = 0; dd < 8; dd++)//输出二进制结果 { for (i = 0; i < 64; i++) { if (count[dd][i] == duis) { CSS = i; for (j = 0; j < 6; j++) //把值转换为二进制 { b = CSS / 2; bin[j] = CSS % 2; CSS = b; if (CSS == 0)//化到最后都会从2或1化到0 { for (d = j + 1; d < 6; d++) //补位添0,成为6bit { bin[d] = 0; } for (e = 5; e >= 0; e--) { bina[5 - e] = bin[e]; } break; } } for (e = 0; e < 6; e++) { cout << bina[e]; } cout << "\t"; } } for (jj = 0; jj < 6; jj++)//合并为一个数组 { CDc[(jj + 6 * dd)] = bina[jj]; } } for (i = 48; i < 56; i++)//赋值给数组以便逆置换得到56bit的中间密钥 { CDc[i] = 6; } for (i = 0; i < 56; i++)//PC2逆置换得到中间值 { CD[i] = CDc[PC2c[i] - 1]; } dd = CD[27]; jj = CD[26]; e = CD[25]; CSS = CD[24]; for (i = 27; i >= 4; i--) { CD[i] = CD[i - 4]; } CD[3] = dd; CD[2] = jj; CD[1] = e; CD[0] = CSS; dd = CD[55]; jj = CD[54]; e = CD[53]; CSS = CD[52]; for (i = 55; i >= 32; i--) { CD[i] = CD[i - 4]; } CD[31] = dd; CD[30] = jj; CD[29] = e; CD[28] = CSS; cout << endl << "最初加密的56bit密钥为:\n"; for (i = 0; i < 56; i++) { cout << CD[i]; if ((i + 1) % 14 == 0) cout << "\t"; } for (i = 0; i < 56; i++) { CDC[i] = CD[i]; } //分成两段每段32bit for (i = 0; i < 32; i++) { L[0][i] = m1[i]; } for (i = 32; i < 64; i++) { R[0][i - 32] = m1[i]; } for (qs = 0; qs < 256; qs++) { for (N = 1; N <= 3; N++) { int* ke = kefe.ki(qs, N, CDC);//生成48bit的密钥 for (i = 0; i < 48; i++) { K[N][i] = ke[i]; } for (i = 0; i < 32; i++) //把下一轮的L求出来 { L[N][i] = R[N - 1][i]; } for (i = 0; i < 48; i++) //将32比特R扩展成48比特 { EA[i] = R[N - 1][E[i] - 1]; } for (i = 0; i < 48; i++) //EA和K异或操作 { if (EA[i] == K[N][i]) B[i] = 0; else B[i] = 1; } for (i = 0; i < 48;) //求出Ci的值,并化为4bit的值,最终合并为一个32bit { hang = B[i] * 2 + B[i + 5]; lie = B[i + 1] * 8 + B[i + 2] * 4 + B[i + 3] * 2 + B[i + 4]; C[i / 6] = S[i / 6][hang][lie]; i = i + 6; } for (j = 0; j < 8; j++) { e = C[j]; for (i = 0; i < 4; i++) //把ASCII值转换为二进制 { b = e / 2; binbin[j][i] = e % 2; e = b; if (e == 0)//化到最后都会从2或1化到0 { for (cc = i + 1; cc < 4; cc++) //补位添0,成为4bit { binbin[j][cc] = 0; } break; } } } cc = 0; for (j = 0; j < 8; j++) //32比特记录到一个数组中 { for (i = 3; i >= 0; i--) { Pt[cc] = binbin[j][i]; cc++; } } for (i = 0; i < 32; i++) //P置换退出f函数 { T[i] = Pt[P[i] - 1]; } for (i = 0; i < 32; i++) //L(i-1)和f函数输出异或操作得到Ri { if (T[i] == L[N - 1][i]) R[N][i] = 0; else R[N][i] = 1; } } if ((M[0] == L[3][0]) && (M[1] == L[3][1]) && (M[2] == L[3][2]) && (M[3] == L[3][3]) && (M[4] == L[3][4]) && (M[5] == L[3][5]) && (M[6] == L[3][6]) && (M[7] == L[3][7]) && (M[8] == L[3][8]) && (M[9] == L[3][9]) && (M[10] == L[3][10]) && (M[11] == L[3][11]) && (M[12] == L[3][12]) && (M[13] == L[3][13])\ && (M[14] == L[3][14]) && (M[15] == L[3][15]) && (M[16] == L[3][16]) && (M[17] == L[3][17]) && (M[18] == L[3][18]) && (M[19] == L[3][19]) && (M[20] == L[3][20]) && (M[21] == L[3][21]) && (M[22] == L[3][22]) && (M[23] == L[3][23]) && (M[24] == L[3][24]) && (M[25] == L[3][25]) && (M[26] == L[3][26])\ && (M[27] == L[3][27]) && (M[28] == L[3][28]) && (M[29] == L[3][29]) && (M[30] == L[3][30]) && (M[31] == L[3][31]) && (M[32] == R[3][0]) && (M[33] == R[3][1]) && (M[34] == R[3][2]) && (M[35] == R[3][3]) && (M[36] == R[3][4]) && (M[37] == R[3][5]) && (M[38] == R[3][6]) && (M[39] == R[3][7])\ && (M[40] == R[3][8]) && (M[41] == R[3][9]) && (M[42] == R[3][10]) && (M[43] == R[3][11]) && (M[44] == R[3][12]) && (M[45] == R[3][13]) && (M[46] == R[3][14]) && (M[47] == R[3][15]) && (M[48] == R[3][16]) && (M[49] == R[3][17]) && (M[50] == R[3][18]) && (M[51] == R[3][19]) && (M[52] == R[3][20])\ && (M[53] == R[3][21]) && (M[54] == R[3][22]) && (M[55] == R[3][23]) && (M[56] == R[3][24]) && (M[57] == R[3][25]) && (M[58] == R[3][26]) && (M[59] == R[3][27]) && (M[60] == R[3][28]) && (M[61] == R[3][29]) && (M[62] == R[3][30]) && (M[63] == R[3][31])) break; } CDC[56] = 6; CDC[57] = 6; CDC[58] = 6; CDC[59] = 6; CDC[60] = 6; CDC[61] = 6; CDC[62] = 6; CDC[63] = 6; for (i = 0; i < 64; i++) { m[i] = CDC[PC1c[i] - 1]; } cout << "\n\n\t\t穷搜得到64bit的密钥为:\n"; for (i = 0; i < 64; i++) { cout << m[i]; if ((i + 1) % 4 == 0) cout << "\t"; } cout << "\n\t\t最后按照每一个字节含有奇数个1补全,就可以得到最终密钥!\n"; system("PAUSE"); return 0; }