This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplates.go
96 lines (84 loc) · 2.03 KB
/
templates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package mpassgo
import (
"sort"
"strings"
)
type PasswordType [][]byte
var Maximum = PasswordType{
[]byte("anoxxxxxxxxxxxxxxxxx"),
[]byte("axxxxxxxxxxxxxxxxxno"),
}
var Long = PasswordType{
[]byte("CvcvnoCvcvCvcv"),
[]byte("CvcvCvcvnoCvcv"),
[]byte("CvcvCvcvCvcvno"),
[]byte("CvccnoCvcvCvcv"),
[]byte("CvccCvcvnoCvcv"),
[]byte("CvccCvcvCvcvno"),
[]byte("CvcvnoCvccCvcv"),
[]byte("CvcvCvccnoCvcv"),
[]byte("CvcvCvccCvcvno"),
[]byte("CvcvnoCvcvCvcc"),
[]byte("CvcvCvcvnoCvcc"),
[]byte("CvcvCvcvCvccno"),
[]byte("CvccnoCvccCvcv"),
[]byte("CvccCvccnoCvcv"),
[]byte("CvccCvccCvcvno"),
[]byte("CvcvnoCvccCvcc"),
[]byte("CvcvCvccnoCvcc"),
[]byte("CvcvCvccCvccno"),
[]byte("CvccnoCvcvCvcc"),
[]byte("CvccCvcvnoCvcc"),
[]byte("CvccCvcvCvccno"),
}
var Medium = PasswordType{
[]byte("CvcnoCvc"),
[]byte("CvcCvcno"),
}
var Short = PasswordType{
[]byte("Cvcn"),
}
var Basic = PasswordType{
[]byte("aaanaaan"),
[]byte("aannaaan"),
[]byte("aaannaaa"),
}
var Pin = PasswordType{
[]byte("nnnn"),
}
// All valid password types represented as a string->PasswordType map.
var PasswordTypes = map[string]PasswordType{
"maximum": Maximum,
"max": Maximum,
"long": Long,
"medium": Medium,
"med": Medium,
"short": Short,
"basic": Basic,
"pin": Pin,
}
// Gets a password type based on the string pwType.
func GetPasswordType(pwType string) (PasswordType, bool) {
typ, ok := PasswordTypes[strings.ToLower(pwType)]
return typ, ok
}
// Gets the valid password types.
func ValidPasswordTypes() []string {
validTypes := make([]string, len(PasswordTypes))
for k := range PasswordTypes {
validTypes = append(validTypes, k)
}
sort.Strings(validTypes)
return validTypes
}
var runeMap = map[rune]string{
'V': "AEIOU",
'C': "BCDFGHJKLMNPQRSTVWXYZ",
'v': "aeiou",
'c': "bcdfghjklmnpqrstvwxyz",
'A': "AEIOUBCDFGHJKLMNPQRSTVWXYZ",
'a': "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz",
'n': "0123456789",
'o': "@&%?,=[]_:-+*$#!'^~;()/.",
'x': "AEIOUaeiouBCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz0123456789!@#$%^&*()",
}