如何加密,解密和删除plist文件 [英] How to Encrypt, Decrypt and Delete a plist file

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

问题描述

我正在制作一个密码应用程序,用于将信用卡,银行信息等用户登录/密码等存储到plist文件中。我用谷歌搜索,我知道如何使用带密钥的AES加密来加密和解密字符串。我得到了简单的登录和密码工作。我加密并保存登录和密码到NSdata,然后解密并读取它

I am making a password app that stores user logins/password etc for credit card, bank info etc into a plist file. I have googled and I know how to encrypt and decrypt a string using AES encryption with key. I got that to work for simple login and password. I encrypt and save the login and password to NSdata and then decrypt and read it

- (NSData *)AES256EncryptWithKey:(NSString *)key;
- (NSData *)AES256DecryptWithKey:(NSString *)key;


- (NSData*) encryptString:(NSString*)plaintext withKey:(NSString*)key;
- (NSString*) decryptData:(NSData*)ciphertext withKey:(NSString*)key;

我想要做的是当用户通过按下主页按钮退出我的应用程序时,我想要加密password.plist文件将其保存为加密数据文件,然后从他的iPhone中删除可读的password.plist xml文件。 (password.plist文件将有多行,值如信用卡1信息,信用卡2信息等)

What I want to do is when the user exits my app by pushing the home button, I want to encrypt the password.plist file save it as an encrypted datafile and then delete the readable password.plist xml file from his iPhone. (password.plist file will have multiple rows, values e.g. credit card1 info, credit card2 info etc)

当用户重新登录时,我想要解密并重新创建密码。 plist文件。有人知道如何做到这一点吗?

When the user logs back in I want to decrypt and recreate password.plist file. Anyone know how this can be done?

推荐答案


  • 您可以使用钥匙串服务来加密密码

  • 您可以使用 NSFileProtectionComplete 为您加密plist文件。

    • you could use Keychain Services to encrypt the password for you.
    • you could use NSFileProtectionComplete to encrypt your plist file for you.
    • 在尝试创建自己的协议之前,最好依赖已经正确实施加密协议的其他人(例如,在您的系统中,加密数据的完整性应该是保证?)。 Apple已经在这方面做得很好,所以只需使用他们的东西。

      It's always best to rely on someone else having implemented an encryption protocol properly, before you try to create your own protocol (for example, where in your system would the integrity of the encrypted data be ensured?). Apple have already done a pretty good job in this regard, so just use their stuff.

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

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