加密/解密.plist文件ios [英] Encrypt/decrypt .plist file ios

查看:986
本文介绍了加密/解密.plist文件ios的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个plist与一些存储的数据,并希望加密解密,所以它不可读使用目标c。我已经阅读了关于AES加密等等,但我希望整个plist被加密一些如何不是plist中的字符串....



任何帮助将非常感谢

解决方案

由howanghk提供的链接包含有错误的代码。在该网页上应用由InoriXu提供的修复以解决问题。您必须修改加密和解密功能。​​



所以在一行之后:

  const char * password = [pass UTF8String]; 

add:

 code> const int passwordLen = [pass length]; 

更改行:

  key [i] = password!= 0? *密码++:0; 

into:

 code> key [i] = i< passwordLen!= 0? *密码++:0; 

代码本身仍然添加了一些空格填充,但如果需要加密属性列表,你会很好。


i have a plist with some stored data and want to encrypt decrypt so it's not readable using objective c. i've read about AES encryption etc but i want the whole plist to be encrypted some how not the strings in the plist....

any help will be really appreciated.

解决方案

The link provided by howanghk contains code with a bug. Apply fix provided by InoriXu on that webpage to resolve the issue. You have to modify both encrypt and decrypt functions.

So after a line:

const char *password = [pass UTF8String];

add:

const int passwordLen = [pass length];

And change line:

key[i] = password != 0 ? *password++ : 0;

into:

key[i] = i < passwordLen != 0 ? *password++ : 0;

The code itself still adds some space padding behind, but if you need it to encrypt a property list, you'll be fine.

这篇关于加密/解密.plist文件ios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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