Get fileSize of info.plist to prevent piracy

前端 未结 4 1199
梦毁少年i
梦毁少年i 2020-12-23 12:38

I\'m trying to put anti-piracy code in my app. The previous answer to this (which I can\'t link to because of my member status - sucks) can be easily countered, since the \"

4条回答
  •  借酒劲吻你
    2020-12-23 13:14

    You might prevent the noobish crackers from finding references to "SignerIdentity" in your code by applying ROT13 or a similar simple obscuring algorithm http://en.wikipedia.org/wiki/ROT13

    After applying ROT13, "SignerIdentity" would become "FvtareVqragvgl".

    Anyway, the answer to your question (how you get the size of the Info.plist file):

    NSBundle *bundle = [NSBundle mainBundle];
    NSString* bundlePath = [bundle bundlePath];
    
    NSFileManager *fileManager = [NSFileManager defaultManager];
    
    NSString* path = [NSString stringWithFormat:@"%@/Info.plist", bundlePath ];
    
    NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:path 
                                                                 error:NULL];
    
    if (fileAttributes != nil) {
        NSNumber *fileSize;
    
        if (fileSize = [fileAttributes objectForKey:NSFileSize]) {
            NSLog(@"File size: %qi\n", [fileSize unsignedLongLongValue]);
        }           
    }
    

    Also keep in mind that the size (in bytes) of the Info.plist in your Xcode project directory and the Info.plist inside the bundle may differ. You probably want to build the game once, then look at the size of /Info.plist and then update your antipiracy code.

提交回复
热议问题