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 (
// 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
return "", fmt.Errorf("unknown Template %q; available [maximum, long, medium, short, pin, name, phrase, basic]", s)
var templates = map[Template][]string{
Maximum: {
Long: {
Medium: {
Short: {
Pin: {
Name: {
Phrase: {
"cvcc cvc cvccvcv cvc",
"cvc cvccvcvcv cvcv",
"cv cvccv cvc cvcvccv",
Basic: {
var characters = map[string]string{
"V": "AEIOU",
"v": "aeiou",
"c": "bcdfghjklmnpqrstvwxyz",
"a": "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz",
"n": "0123456789",
"o": "@&%?,=[]_:-+*$#!'^~;()/.",
"x": "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz0123456789!@#$%^&*()",
" ": " ",