역시 extable 키 값을 각각 지정 해주시면 됩니다. ^^아래의 값은 임시 적입니다.~
const unsigned char extable[4] = {0x1D, 0x1D, 0x1B, 0xF1};
void IntToByte(int num, unsigned char* value)
{
value[0] = ((unsigned char)(num >> 24)) ^ extable[0];
value[1] = ((unsigned char)(num >> 16)) ^ extable[1];
value[2] = ((unsigned char)(num >> 8)) ^ extable[2];
value[3] = ((unsigned char)(num)) ^ extable[3];
}
void IntToByteNon(int num, unsigned char* value)
{
value[0] = ((unsigned char)(num >> 24));
value[1] = ((unsigned char)(num >> 16));
value[2] = ((unsigned char)(num >> 8));
value[3] = ((unsigned char)(num));
}
int ByteToInt(unsigned char* value)
{
int retV = 0;
retV = (((value[0] & 0xFF) ^ extable[0]) << 24) |
(((value[1] & 0xFF) ^ extable[1]) << 16) |
(((value[2] & 0xFF) ^ extable[2]) << 8) |
((value[3] & 0xFF) ^ extable[3]);
return retV;
}
int ByteToIntNon(unsigned char* value)
{
int retV = 0;
retV = (((value[0] & 0xFF)) << 24) |
(((value[1] & 0xFF)) << 16) |
(((value[2] & 0xFF)) << 8) |
((value[3] & 0xFF));
return retV;
}
- (int) setInt_XOR:(int)value {
IntToByte(value,_changeBuf);
return ByteToIntNon(_changeBuf);
}
- (int) getInt_XOR:(int)value {
memset(_changeBuf, 0x00, 4);
IntToByteNon(value,_changeBuf);
return ByteToInt(_changeBuf);
}