1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include <iostream> #include <stdlib.h> #include <string.h> using namespace std; void xtea(int v[2], int k[4]) { unsigned int v0 = v[0], v1 = v[1], j = 0x9E3779B9, sum = j * 32,i; for (i = 0; i < 32; i++) { v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum >> 11) & 3]); sum -= j; v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]); } v[0] = v0; v[1] = v1; k[0] += 789; k[3] += 135; } int main() { int z[4] = { 424242, 325477, 523007, 424242 }; int flag[8][2] = { 0xD118C7B2,0x7FC3F3A8,0x4A19F2DA,0x472469E1, 0x7C682864,0x50C0E3D1,0x0C595670B,0x2EE07578, 0x0D040A3F0,0x0C5590286,0x0D82B07A8,0x0D5978C2C, 0x4E2BC556,0x79E2E90,0x0C7A353B5,0x493995B }; for (int i = 0; i < 8; i++) { xtea(flag[i], z); cout << (char)flag[i][0] << (char)flag[i][1]; } system("pause"); return 0; }
|