You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.0 KiB

package spectre
import (
"fmt"
"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 "", fmt.Errorf("unknown Template %q; available [maximum, long, medium, short, pin, name, phrase, basic]", s)
}
}
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!@#$%^&*()",
" ": " ",
}