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 35 36 37 38 39 40 41 42 43
| #include <cstdio> using namespace std; unsigned char enc[32] = { 0x88, 0x6A, 0xB0, 0xC9, 0xAD, 0xF1, 0x33, 0x33, 0x94, 0x74, 0xB5, 0x69, 0x73, 0x5F, 0x30, 0x62, 0x4A, 0x33, 0x63, 0x54, 0x5F, 0x30, 0x72, 0x31, 0x65, 0x6E, 0x54, 0x65, 0x44, 0x3F, 0x21, 0x7D }; void TEA_decrypt1(const int ptr1,const int ptr2){ unsigned int sum=(-0x21524111)*32,enc1=0,enc2=0; enc1=(enc[ptr1])|(enc[ptr1+1]<<8)|(enc[ptr1+2]<<16)|(enc[ptr1+3]<<24), enc2=(enc[ptr2])|(enc[ptr2+1]<<8)|(enc[ptr2+2]<<16)|(enc[ptr2+3]<<24); unsigned int v0=enc1,v1=enc2; for(int i=0;i<32;i++){ v1-=((((v0<<4)+3412)^(v0+sum)^((v0<<5)+4123))); v0-=((((v1<<4)+1234)^(v1+sum)^((v1<<5)+2341))); sum+=0x21524111; }; enc[ptr1]=v0&0xFF,enc[ptr1+1]=(v0>>8)&0xFF,enc[ptr1+2]=(v0>>16)&0xFF,enc[ptr1+3]=(v0>>24)&0xFF, enc[ptr2]=v1&0xFF,enc[ptr2+1]=(v1>>8)&0xFF,enc[ptr2+2]=(v1>>16)&0xFF,enc[ptr2+3]=(v1>>24)&0xFF; return; }; void TEA_decrypt2(const int ptr1,const int ptr2){ unsigned int sum=0xDEADBEEF*32,enc1=0,enc2=0; enc1=(enc[ptr1])|(enc[ptr1+1]<<8)|(enc[ptr1+2]<<16)|(enc[ptr1+3]<<24), enc2=(enc[ptr2])|(enc[ptr2+1]<<8)|(enc[ptr2+2]<<16)|(enc[ptr2+3]<<24); unsigned int v0=enc1,v1=enc2; for(int i=0;i<32;i++){ v1-=((((v0<<4)+3412)^(v0+sum)^((v0<<5)+4123))); v0-=((((v1<<4)+1234)^(v1+sum)^((v1<<5)+2341))); sum-=0xDEADBEEF; }; enc[ptr1]=v0&0xFF,enc[ptr1+1]=(v0>>8)&0xFF,enc[ptr1+2]=(v0>>16)&0xFF,enc[ptr1+3]=(v0>>24)&0xFF, enc[ptr2]=v1&0xFF,enc[ptr2+1]=(v1>>8)&0xFF,enc[ptr2+2]=(v1>>16)&0xFF,enc[ptr2+3]=(v1>>24)&0xFF; return; }; int main(void){ TEA_decrypt2(3,7); TEA_decrypt2(2,6); TEA_decrypt2(1,5); TEA_decrypt1(0,4); for(register int i=0;i<32;i++) printf("%c",enc[i]); return 0; };
|