111 lines
2.0 KiB
Go
111 lines
2.0 KiB
Go
package spectre
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
// Template is a template type
|
|
type Template string
|
|
|
|
const (
|
|
Maximum Template = "Maximum"
|
|
Long Template = "Long"
|
|
Medium Template = "Medium"
|
|
Short Template = "Short"
|
|
Pin Template = "PIN"
|
|
Name Template = "Name"
|
|
Phrase Template = "Phrase"
|
|
Basic Template = "Basic"
|
|
)
|
|
|
|
// ParseTemplate parses a Template from s
|
|
func ParseTemplate(s string) (Template, error) {
|
|
switch strings.ToLower(s) {
|
|
case "maximum", "max":
|
|
return Maximum, nil
|
|
case "long", "l":
|
|
return Long, nil
|
|
case "medium", "med":
|
|
return Medium, nil
|
|
case "short", "sh":
|
|
return Short, nil
|
|
case "pin":
|
|
return Pin, nil
|
|
case "name":
|
|
return Name, nil
|
|
case "phrase":
|
|
return Phrase, nil
|
|
case "basic":
|
|
return Basic, nil
|
|
default:
|
|
return "", errors.New("unknown Template")
|
|
}
|
|
}
|
|
|
|
var templates = map[Template][]string{
|
|
Maximum: {
|
|
"anoxxxxxxxxxxxxxxxxx",
|
|
"axxxxxxxxxxxxxxxxxno",
|
|
},
|
|
Long: {
|
|
"CvcvnoCvcvCvcv",
|
|
"CvcvCvcvnoCvcv",
|
|
"CvcvCvcvCvcvno",
|
|
"CvccnoCvcvCvcv",
|
|
"CvccCvcvnoCvcv",
|
|
"CvccCvcvCvcvno",
|
|
"CvcvnoCvccCvcv",
|
|
"CvcvCvccnoCvcv",
|
|
"CvcvCvccCvcvno",
|
|
"CvcvnoCvcvCvcc",
|
|
"CvcvCvcvnoCvcc",
|
|
"CvcvCvcvCvccno",
|
|
"CvccnoCvccCvcv",
|
|
"CvccCvccnoCvcv",
|
|
"CvccCvccCvcvno",
|
|
"CvcvnoCvccCvcc",
|
|
"CvcvCvccnoCvcc",
|
|
"CvcvCvccCvccno",
|
|
"CvccnoCvcvCvcc",
|
|
"CvccCvcvnoCvcc",
|
|
"CvccCvcvCvccno",
|
|
},
|
|
Medium: {
|
|
"CvcnoCvc",
|
|
"CvcCvcno",
|
|
},
|
|
Short: {
|
|
"Cvcn",
|
|
},
|
|
Pin: {
|
|
"nnnn",
|
|
},
|
|
Name: {
|
|
"cvccvcvcv",
|
|
},
|
|
Phrase: {
|
|
"cvcc cvc cvccvcv cvc",
|
|
"cvc cvccvcvcv cvcv",
|
|
"cv cvccv cvc cvcvccv",
|
|
},
|
|
Basic: {
|
|
"aaanaaan",
|
|
"aannaaan",
|
|
"aaannaaa",
|
|
},
|
|
}
|
|
|
|
var characters = map[string]string{
|
|
"V": "AEIOU",
|
|
"C": "BCDFGHJKLMNPQRSTVWXYZ",
|
|
"v": "aeiou",
|
|
"c": "bcdfghjklmnpqrstvwxyz",
|
|
"A": "AEIOUBCDFGHJKLMNPQRSTVWXYZ",
|
|
"a": "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz",
|
|
"n": "0123456789",
|
|
"o": "@&%?,=[]_:-+*$#!'^~;()/.",
|
|
"x": "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz0123456789!@#$%^&*()",
|
|
" ": " ",
|
|
}
|