Add option to select two flavors of password generator: random and apple's (keychain)
This commit is contained in:
parent
3cf88dcbc8
commit
ad0c39b541
5 changed files with 59 additions and 11 deletions
|
|
@ -36,12 +36,7 @@ extension DefaultsKeys {
|
|||
static let isHideOTPOn = DefaultsKey<Bool>("isHideOTPOn")
|
||||
static let isRememberPassphraseOn = DefaultsKey<Bool>("isRememberPassphraseOn")
|
||||
static let isShowFolderOn = DefaultsKey<Bool>("isShowFolderOn")
|
||||
|
||||
static let passwordGenerationMethod = DefaultsKey<String>("passwordGenerationMethod")
|
||||
static let passwordGeneratorFlavor = DefaultsKey<String>("passwordGeneratorFlavor")
|
||||
|
||||
|
||||
func initDefaultKeys() {
|
||||
if Defaults[.passwordGenerationMethod] == "" {
|
||||
Defaults[.passwordGenerationMethod] = "Random"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ class Utils {
|
|||
}
|
||||
|
||||
static func generatePassword(length: Int) -> String{
|
||||
switch Defaults[.passwordGenerationMethod] {
|
||||
switch Defaults[.passwordGeneratorFlavor] {
|
||||
case "Random":
|
||||
return randomString(length: length)
|
||||
case "Keychain":
|
||||
case "Apple":
|
||||
return Keychain.generatePassword()
|
||||
default:
|
||||
return randomString(length: length)
|
||||
|
|
@ -138,6 +138,11 @@ class Utils {
|
|||
}
|
||||
return attributedPassword
|
||||
}
|
||||
static func initDefaultKeys() {
|
||||
if Defaults[.passwordGeneratorFlavor] == "" {
|
||||
Defaults[.passwordGeneratorFlavor] = "Random"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://gist.github.com/NikolaiRuhe/eeb135d20c84a7097516
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue