如何使文件密码在Swift中编程保护 [英] How to make File password protected in Swift programatically
问题描述
我想要创建一个iOS应用,用户将使用密码锁定一个文件并使用相同的密码打开该文件。
I want to make an iOS app, User will lock a file with password and open that file using same password.
我研究了加密和解密, a href =https://github.com/krzyzanowskim/CryptoSwift =nofollow noreferrer> CryptoSwift 我添加了它与我的应用程序,并得到一些关于字符串加密和解密使用这个 StackoverflowPost
I studied about Encryption and Decryption, got CryptoSwift I added it with my application, and to get some idea about String encryption and decryption using this StackoverflowPost
如果字符串加密解密运行良好,但我不知道如何处理文件。
In case of string Encryption decryption is working well but I could not get idea how to deal with file.
我试着用下面的语法,但无法弄清楚。
I tried with following syntax, but could not figure out.
do {
let aes = try AES(key: "passwordpassword", iv: "drowssapdrowssap")
let fdata = Data.init(contentsOf: URL.init(fileURLWithPath:"/path/file.dat")).encrypt(cipher: aes)
}
catch {}
我是Swift新手,
感谢提前
推荐答案
文件大小,但如果您尝试在钥匙串中保存数据系统?
I don't know how big your file, but if you try to save your data in the keychain system?
这篇关于如何使文件密码在Swift中编程保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!