获取info.plist的fileSize以防止盗版 [英] Get fileSize of info.plist to prevent piracy

查看:117
本文介绍了获取info.plist的fileSize以防止盗版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用中添加反盗版代码。由于可以使用十六进制编辑器在二进制文件中查找和替换SignerIdentity字符串,因此可以轻松地解决之前对此的回答(由于我的成员状态而无法链接)。

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 "SignerIdentity" string can be looked for and replaced in the binary using a hex editor.

相反,检查info.plist文件的fileSize并将其与参考值进行比较听起来更加可靠(因为info.plist在这里和那里开始时会被修改该应用程序)。我该怎么办?我尝试了以下但它记录了0。

Instead, checking the fileSize of the info.plist file and comparing it to a reference value sounds more solid (since the info.plist is getting modified here and there when cracking the app). How would I do that? I tried the following but it logs 0.

NSBundle *bundle = [NSBundle mainBundle];
NSDictionary *mainDictionary = [bundle infoDictionary];
NSLog(@"%d", [mainDictionary fileSize]);


推荐答案

你可能会阻止noobish破解者找到 SignerIdentity在您的代码中通过应用ROT13或类似的简单模糊算法
http:// en。 wikipedia.org/wiki/ROT13

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

申请ROT13后,SignerIdentity将成为FvtareVqragvgl。

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

无论如何,您的问题的答案(如何获得Info.plist文件的大小):

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]);
    }           
}

还要记住大小(以字节为单位)您的Xcode项目目录中的 Info.plist 和捆绑包内的 Info.plist 可能有所不同。您可能想要构建一次游戏,然后查看< your app bundle.app> /Info.plist 的大小,然后更新您的反盗版代码。

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 <your app bundle.app>/Info.plist and then update your antipiracy code.

这篇关于获取info.plist的fileSize以防止盗版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆