-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
75 lines (59 loc) · 1.69 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"math/rand/v2"
"strconv"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
var (
application fyne.App
window fyne.Window
numbers = false
numbersArr = []rune("12345678901234567890")
special = false
specialArr = []rune("!@#$%&!@#$%&!@#$%&")
capital = false
capitalArr = []rune("QWERTYUIOPASDFGHJKLZXCVBNM")
passwd = ""
)
func main() {
application = app.New()
window = application.NewWindow("password generator")
application.Settings().SetTheme(myTheme{})
numbersChek := widget.NewCheck("numbers", func(b bool) { numbers = b })
specialCheck := widget.NewCheck("special chars", func(b bool) { special = b })
capitalCheck := widget.NewCheck("capital letters", func(b bool) { capital = b })
checks := container.NewHBox(numbersChek, specialCheck, capitalCheck)
checksCent := container.NewCenter(checks)
passText := widget.NewLabel("4")
passSlid := widget.NewSlider(4, 40)
passSlid.OnChanged = func(f float64) {
passText.Text = strconv.Itoa(int(f))
passText.Refresh()
}
passCont := container.New(&InputLayout{}, passSlid, passText)
output := widget.NewEntry()
genPassBtn := widget.NewButton("Generate", func() {
chars := []rune("qwertyuiopasdfghjklzxcvbnm")
passwd = ""
if numbers {
chars = append(chars, numbersArr...)
}
if special {
chars = append(chars, specialArr...)
}
if capital {
chars = append(chars, capitalArr...)
}
for range int(passSlid.Value) {
passwd += string(chars[rand.IntN(len(chars))])
}
output.Text = passwd
output.Refresh()
})
mainBox := container.NewVBox(checksCent, passCont, genPassBtn, output)
window.SetContent(mainBox)
window.ShowAndRun()
}