@@ -9,16 +9,16 @@ import (
99
1010const (
1111 // LengthWeak weak length password
12- LengthWeak = 6
12+ LengthWeak uint = 6
1313
1414 // LengthOK ok length password
15- LengthOK = 12
15+ LengthOK uint = 12
1616
1717 // LengthStrong strong length password
18- LengthStrong = 24
18+ LengthStrong uint = 24
1919
2020 // LengthVeryStrong very strong length password
21- LengthVeryStrong = 36
21+ LengthVeryStrong uint = 36
2222
2323 // DefaultLetterSet is the letter set that is defaulted to - just the
2424 // alphabet
@@ -73,7 +73,7 @@ type Generator struct {
7373// what type of password to generate
7474type Config struct {
7575 // Length is the length of password to generate
76- Length int
76+ Length uint
7777
7878 // CharacterSet is the setting to manually set the
7979 // character set
@@ -191,7 +191,7 @@ func (g Generator) Generate() (*string, error) {
191191 characterSet := strings .Split (g .Config .CharacterSet , "" )
192192 max := big .NewInt (int64 (len (characterSet )))
193193
194- for i := 0 ; i < g .Config .Length ; i ++ {
194+ for i := uint ( 0 ) ; i < g .Config .Length ; i ++ {
195195 val , err := rand .Int (rand .Reader , max )
196196 if err != nil {
197197 return nil , err
@@ -203,9 +203,9 @@ func (g Generator) Generate() (*string, error) {
203203
204204// GenerateMany generates multiple passwords with length set
205205// in the config
206- func (g Generator ) GenerateMany (amount int ) ([]string , error ) {
206+ func (g Generator ) GenerateMany (amount uint ) ([]string , error ) {
207207 var generated []string
208- for i := 0 ; i < amount ; i ++ {
208+ for i := uint ( 0 ) ; i < amount ; i ++ {
209209 str , err := g .Generate ()
210210 if err != nil {
211211 return nil , err
@@ -217,11 +217,11 @@ func (g Generator) GenerateMany(amount int) ([]string, error) {
217217}
218218
219219// GenerateWithLength generate one password with set length
220- func (g Generator ) GenerateWithLength (length int ) (* string , error ) {
220+ func (g Generator ) GenerateWithLength (length uint ) (* string , error ) {
221221 var generated string
222222 characterSet := strings .Split (g .Config .CharacterSet , "" )
223223 max := big .NewInt (int64 (len (characterSet )))
224- for i := 0 ; i < length ; i ++ {
224+ for i := uint ( 0 ) ; i < length ; i ++ {
225225 val , err := rand .Int (rand .Reader , max )
226226 if err != nil {
227227 return nil , err
@@ -232,9 +232,9 @@ func (g Generator) GenerateWithLength(length int) (*string, error) {
232232}
233233
234234// GenerateManyWithLength generates multiple passwords with set length
235- func (g Generator ) GenerateManyWithLength (amount , length int ) ([]string , error ) {
235+ func (g Generator ) GenerateManyWithLength (amount , length uint ) ([]string , error ) {
236236 var generated []string
237- for i := 0 ; i < amount ; i ++ {
237+ for i := uint ( 0 ) ; i < amount ; i ++ {
238238 str , err := g .GenerateWithLength (length )
239239 if err != nil {
240240 return nil , err
0 commit comments