-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (50 loc) · 817 Bytes
/
main.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
package main
import (
"fmt"
"math/rand"
"time"
)
func getChar(i int) []byte {
var r []byte
if i == 0 {
for i := 33; i < 126; i++ {
r = append(r, byte(i))
}
}
if i == 1 {
for i := 48; i < 57; i++ {
r = append(r, byte(i))
}
}
if i == 2 {
for i := 48; i < 57; i++ {
r = append(r, byte(i))
}
for i := 65; i < 90; i++ {
r = append(r, byte(i))
}
}
if i == 3 {
for i := 48; i < 57; i++ {
r = append(r, byte(i))
}
for i := 65; i < 90; i++ {
r = append(r, byte(i))
}
for i := 97; i < 122; i++ {
r = append(r, byte(i))
}
}
return r
}
func genPass(i int, c []byte) string {
rand.Seed(time.Now().UnixNano())
var r []byte
for a := 0; a < i; a++ {
r = append(r, c[rand.Intn(len(c))])
}
return string(r)
}
func main() {
fmt.Print(genPass(24, getChar(0)))
}