use keychain to store pgp passphrase and git password

This commit is contained in:
Bob Sun 2017-02-19 22:10:36 +08:00
parent ceb52a5b33
commit 90709675a3
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
10 changed files with 86 additions and 19 deletions

View file

@ -14,7 +14,7 @@ extension PasswordEntity {
var password: Password?
let encryptedDataPath = URL(fileURLWithPath: "\(Globals.repositoryPath)/\(rawPath!)")
let encryptedData = try Data(contentsOf: encryptedDataPath)
let decryptedData = try PasswordStore.shared.pgp.decryptData(encryptedData, passphrase: Defaults[.pgpKeyPassphrase])
let decryptedData = try PasswordStore.shared.pgp.decryptData(encryptedData, passphrase: PasswordStore.shared.pgpKeyPassphrase!)
let plainText = String(data: decryptedData, encoding: .ascii) ?? ""
password = Password(name: name!, plainText: plainText)
return password