Add eff short wordlist

This commit is contained in:
Yishi Lin 2020-02-23 03:48:10 +08:00
parent 5e4fbaec8a
commit 610eef411f
6 changed files with 1326 additions and 5 deletions

View file

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View file

@ -0,0 +1,12 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"data" : [
{
"idiom" : "universal",
"filename" : "eff_long_wordlist.txt"
}
]
}

View file

@ -6,7 +6,7 @@
"data" : [ "data" : [
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "EN_wordlist.txt", "filename" : "eff_short_wordlist.txt",
"universal-type-identifier" : "public.plain-text" "universal-type-identifier" : "public.plain-text"
} }
] ]

View file

@ -58,11 +58,18 @@ public enum PasswordGeneratorFlavor: String {
private static func generateXKCD(length: Int) -> String { private static func generateXKCD(length: Int) -> String {
// Get the word list // Get the word list
let bundle = Bundle(identifier: Globals.passKitBundleIdentifier)! let bundle = Bundle(identifier: Globals.passKitBundleIdentifier)!
guard let asset = NSDataAsset(name: "WordLists", bundle: bundle), let wordlistNames = [
"eff_long_wordlist",
"eff_short_wordlist"
]
let data = wordlistNames.map{ name -> String in
guard let asset = NSDataAsset(name: name, bundle: bundle),
let data = String(data: asset.data, encoding: .utf8) else { let data = String(data: asset.data, encoding: .utf8) else {
return "" return ""
} }
let words = data.splitByNewline() return data
}
let words = data.joined(separator: "\n").splitByNewline()
// Generate a password // Generate a password
let delimiters = "0123456789!@#$%^&*_+-=" let delimiters = "0123456789!@#$%^&*_+-="