support ASCII armor encrypted PGP keys

This commit is contained in:
Bob Sun 2017-02-17 13:44:25 +08:00
parent b5313b1dfc
commit a5f13a1e8a
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
7 changed files with 377 additions and 66 deletions

View file

@ -11,10 +11,16 @@ import SwiftyUserDefaults
extension DefaultsKeys {
// static let pgpKeyURL = DefaultsKey<URL?>("pgpKeyURL")
static let pgpKeySource = DefaultsKey<String?>("pgpKeySource")
static let pgpPublicKeyURL = DefaultsKey<URL?>("pgpPublicKeyURL")
static let pgpPrivateKeyURL = DefaultsKey<URL?>("pgpPrivateKeyURL")
static let pgpPublicKeyArmor = DefaultsKey<String?>("pgpPublicKeyArmor")
static let pgpPrivateKeyArmor = DefaultsKey<String?>("pgpPrivateKeyArmor")
static let pgpKeyPassphrase = DefaultsKey<String?>("pgpKeyPassphrase")
static let pgpPrivateKeyURLPassphrase = DefaultsKey<String?>("pgpPrivateKeyURLPassphrase")
static let pgpPrivateKeyArmorPassphrase = DefaultsKey<String?>("pgpPrivateKeyArmorPassphrase")
static let pgpKeyID = DefaultsKey<String?>("pgpKeyID")
static let pgpKeyUserID = DefaultsKey<String?>("pgpKeyUserID")

View file

@ -58,6 +58,18 @@ class Utils {
controller.present(alert, animated: true, completion: completion)
}
static func removePGPKeys() {
removeFileIfExists(atPath: Globals.pgpPublicKeyPath)
removeFileIfExists(atPath: Globals.pgpPrivateKeyPath)
Defaults.remove(.pgpKeySource)
Defaults.remove(.pgpKeyPassphrase)
Defaults.remove(.pgpPublicKeyArmor)
Defaults.remove(.pgpPrivateKeyArmor)
Defaults.remove(.pgpPrivateKeyURL)
Defaults.remove(.pgpPublicKeyURL)
Defaults.remove(.pgpKeyID)
}
}
// https://gist.github.com/NikolaiRuhe/eeb135d20c84a7097516