Created
October 7, 2015 17:53
-
-
Save DevAlloy/88e218729afd556205ed to your computer and use it in GitHub Desktop.
Алгоритм генерации строки, которую хотим спрятать
This file contains 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
- (NSString *)uuidForToken { | |
unsigned char obfuscatedSecretKey[] = {0xa, 0xd7, 0x55, 0x2f, 0x94}; | |
// Get the SHA1 of a class name, to form the obfuscator. | |
unsigned char obfuscator[CC_SHA1_DIGEST_LENGTH]; | |
NSData *className = [NSStringFromClass([self class]) | |
dataUsingEncoding:NSUTF8StringEncoding]; | |
CC_SHA1(className.bytes, (CC_LONG)className.length, obfuscator); | |
// XOR the class name against the obfuscated key, to form the real key. | |
unsigned char actualSecretKey[sizeof(obfuscatedSecretKey)]; | |
for (int i=0; i<sizeof(obfuscatedSecretKey); i++) { | |
// алгоритм модифифированный, добавлено i % sizeof(obfuscator) | |
// для того, чтобы пройтись по всему сообщению | |
actualSecretKey[i] = obfuscatedSecretKey[i] ^ obfuscator[i % sizeof(obfuscator)]; | |
} | |
NSString *result = [[NSString alloc] initWithBytes:actualSecretKey length:sizeof(obfuscatedSecretKey) encoding:NSUTF8StringEncoding]; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment