Created
May 17, 2014 15:11
-
-
Save diederikh/94d879f1b4e802d0cf56 to your computer and use it in GitHub Desktop.
Obfuscate data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fill this out with whatever you want. Use the same string | |
// and algorithm to scramble the files on the server. | |
static unsigned char secretString[SECRET_STRING_LENGTH]; | |
- (NSData *)scrambleOrDescrambleData:(NSData*)input | |
{ | |
unsigned char *outputBytes = malloc(input.length); | |
memcpy(outputBytes, input.bytes, input.length); | |
for (int i = 0; i < input.length; i++) | |
{ | |
outputBytes[i] = outputBytes[i] ^ secretString[i % SECRET_STRING_LENGTH]; | |
} | |
NSData *outputData = [[NSData alloc] initWithBytes:outputBytes length:input.length]; | |
free(outputBytes); | |
return outputData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment