about block XTEA in C code
i want to send/receive encryption data with differnet endian systems it is possible? i heard that that is possible to same endian systems xxtea code is block xtea in internet...
#define MXA (((z>>5^y<<2) + (y>>3^z<<4)) ^ ((sum^y) + (xt_keyA[(p&3)^e] ^ z)))
void Encode(unsigned long *encode_data, unsigned char dataLength)
{
unsigned long y, z,sum;
unsigned long p, e,round;
dataLength=0;
round = 10;
sum = 0;
z = encode_data[1];
do {
sum += 0x12345678;
e = (sum >> 2) & 3;
for (p=0; p< 1; p++)
{
y = encode_data[p+1];
z = encode_data[p] += MXA;
}
y = encode_data[0];
z = encode_data[1] += MXA;
} while (--round);
}
void DecodeA(unsigned long *decode_data, unsigned char dataLength)
{
unsigned long y, z,sum;
unsigned long p, e;
dataLength=0;
sum = 10*0x12345678;
y = decode_data[0];
do {
e = (sum >> 2) & 3;
for (p=1; p>0; p--)
{
z = decode_data[p-1];
y = decode_data[p] -= MXA;
}
z = decode_data[1];
y = decode_data[0] -= MXA;
} while ((sum -= 0x12345678) != 0)开发者_运维知识库;
}
精彩评论