refactor PasswordEntitiy model, add decrypt extension
This commit is contained in:
parent
a2b3d450ba
commit
d44aec6527
4 changed files with 51 additions and 25 deletions
|
|
@ -16,23 +16,7 @@ class PasswordDetailViewController: UIViewController {
|
|||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
let encryptedDataURL = URL(fileURLWithPath: "\(Globals.shared.documentPath)/\(passwordEntity!.rawPath!)")
|
||||
let fm = FileManager.default
|
||||
if fm.fileExists(atPath: encryptedDataURL.path){
|
||||
print("file exist")
|
||||
} else {
|
||||
print("file doesnt exist")
|
||||
}
|
||||
|
||||
do {
|
||||
let encryptedData = try Data(contentsOf: encryptedDataURL)
|
||||
let decryptedData = try PasswordStore.shared.pgp.decryptData(encryptedData, passphrase: Defaults[.pgpKeyPassphrase])
|
||||
let plain = String(data: decryptedData, encoding: .ascii) ?? ""
|
||||
print(plain)
|
||||
passwordTextView.text = plain
|
||||
} catch let error as NSError {
|
||||
print(error.debugDescription)
|
||||
}
|
||||
|
||||
let password = passwordEntity!.decrypt()!
|
||||
passwordTextView.text = password.password
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue