C to LiveCode Conversion
Posted: Wed Dec 16, 2015 9:55 pm
Sorry to bother the list, but I don't know how to do Xor in LiveCode. I have an app deadline of this week and I can't figure now to do a byte Xor conversion. We converted an Objective C app to LiveCode, I have done ALL of the code except a small encryption function. I can't figure how to convert using LiveCode. Any help would be appreciated.
Best,
Todd
Best,
Todd
Code: Select all
- (NSString *) encryptString : (NSString *)sInput{
NSInteger len; //store the length of input string
const NSString *key =@"keycode";
//create data object from the string
NSData *data= [sInput dataUsingEncoding:NSUTF8StringEncoding];
NSData *data1= [sInput dataUsingEncoding:NSUTF8StringEncoding];
//Get pointer to data to obfuscate
char *dataPtr = (char *) [data bytes];
char *tempPtr= (char*) [data1 bytes];
//get pointer to key data
char *keyData =(char *) [[key dataUsingEncoding:NSUTF8StringEncoding] bytes];
//points to each char in seqeunce in the key
char *keyPtr =keyData;
int keyIndex =0 ;
len=[data length];
//for each character in data , xor with current value in key
for (int x=0; x< len; x++){
*tempPtr++ = *dataPtr++ ^ *keyPtr++;
if(++keyIndex == [key length])
keyIndex = 0,keyPtr =keyData;
}
return [[NSString alloc] initWithData:data1 encoding:NSUTF8StringEncoding];
}