change a lot, the structure will be stable this time

This commit is contained in:
Bob Sun 2017-01-22 01:42:36 +08:00
parent 8e997cc868
commit 36bf40741c
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
14 changed files with 579 additions and 208 deletions

View file

@ -7,29 +7,34 @@
//
import UIKit
import SwiftyUserDefaults
class PasswordDetailViewController: UIViewController {
@IBOutlet weak var passwordLabel: UILabel!
var passwordEntity: PasswordEntity?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
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)
passwordLabel.text = plain
} catch let error as NSError {
print(error.debugDescription)
}
passwordLabel.sizeToFit()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}