@@ -6,14 +6,17 @@ import (
6
6
"math/big"
7
7
"math/rand/v2"
8
8
"sync"
9
- "time"
10
9
)
11
10
12
11
var (
13
12
biZero = big .NewInt (0 )
14
13
biOne = big .NewInt (1 )
15
14
)
16
15
16
+ // Sequencer is a deterministic Password Generator that generates all possible
17
+ // combinations of passwords for a Charset and defined number of characters in
18
+ // the password. It lets you move back and forth through the list of possible
19
+ // passwords, and involves no RNG.
17
20
type Sequencer interface {
18
21
// First moves to the first possible password and returns the same.
19
22
First () string
@@ -37,8 +40,6 @@ type Sequencer interface {
37
40
PrevN (n * big.Int ) string
38
41
// Reset cleans up state and moves to the first possible word.
39
42
Reset ()
40
- // SetSeed overrides the seed value for the RNG.
41
- SetSeed (seed uint64 )
42
43
// Stream sends all possible passwords in order to the given channel. If you
43
44
// want to limit output, pass in a *big.Int with the number of passwords you
44
45
// want to be generated and streamed.
@@ -65,7 +66,6 @@ type sequencer struct {
65
66
// interface.
66
67
func NewSequencer (rules ... Rule ) (Sequencer , error ) {
67
68
s := & sequencer {}
68
- s .SetSeed (uint64 (time .Now ().UnixNano ()))
69
69
for _ , rule := range append (basicRules , rules ... ) {
70
70
rule (s )
71
71
}
@@ -201,14 +201,6 @@ func (s *sequencer) Reset() {
201
201
s .First ()
202
202
}
203
203
204
- // SetSeed changes the seed value of the RNG.
205
- func (s * sequencer ) SetSeed (seed uint64 ) {
206
- s .mutex .Lock ()
207
- defer s .mutex .Unlock ()
208
-
209
- s .rng = rand .New (rand .NewPCG (seed , seed + 100 ))
210
- }
211
-
212
204
// Stream sends all possible passwords in order to the given channel. If you
213
205
// want to limit output, pass in a *big.Int with the number of passwords you
214
206
// want to be generated and streamed.
0 commit comments