/**
* 字符串异或加密
*
* @param oldStr 被加密的字符串
* @param x 字符偏移量
*
* @return 加密后的字符串
*/
- (NSString *)getCharArrayUsingString:(NSString *)oldstr withCharOffset:(int)x
{
if (nil == oldstr || [@"" isEqualToString:oldstr]) {
return @"";
}
unichar *charArray = malloc(sizeof(unichar) * (oldstr.length + 1));
int nCount = (int)oldstr.length;
for(int i = 0; i < nCount; i++){
charArray[i] = [oldstr characterAtIndex:i] ^ x;
}
charArray[nCount] = ' ';
NSString *newStr = [NSString stringWithCharacters:charArray length:nCount];
free(charArray);
return newStr;
}