下面这段代码,如果分别在大端和小端机上运行,结果会有什么差异呢?
static WORD32 F(WORD32 data, WORD32 key) { WORD32 t; BYTE v[4], u; /* Key Insersion */ t = data+key; /* Secret Constant */ v[3] = (BYTE)((t>>24)&0xff); v[2] = (BYTE)((t>>16)&0xff); v[1] = (BYTE)((t>> 8)&0xff); v[0] = SecretConstant[t&0xff]; u = v[0]^0x65; v[1] ^= lrot8(u,1); u = v[0]^0x2b; v[2] ^= lrot8(u,5); u = v[0]^0xc9; v[3] ^= lrot8(u,2); /* Rotate */ t = ((WORD32)v[3]<<24)|((WORD32)v[2]<<16)|((WORD32)v[1]<<8)|(WORD32)v[0]; t ^= lrot32(t,9) ^ lrot32(t,22); return t; }
|