Skip to content

Commit f0545cd

Browse files
committed
password sequencer documentation
1 parent c012590 commit f0545cd

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

password/sequencer.go

+4-12
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import (
66
"math/big"
77
"math/rand/v2"
88
"sync"
9-
"time"
109
)
1110

1211
var (
1312
biZero = big.NewInt(0)
1413
biOne = big.NewInt(1)
1514
)
1615

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.
1720
type Sequencer interface {
1821
// First moves to the first possible password and returns the same.
1922
First() string
@@ -37,8 +40,6 @@ type Sequencer interface {
3740
PrevN(n *big.Int) string
3841
// Reset cleans up state and moves to the first possible word.
3942
Reset()
40-
// SetSeed overrides the seed value for the RNG.
41-
SetSeed(seed uint64)
4243
// Stream sends all possible passwords in order to the given channel. If you
4344
// want to limit output, pass in a *big.Int with the number of passwords you
4445
// want to be generated and streamed.
@@ -65,7 +66,6 @@ type sequencer struct {
6566
// interface.
6667
func NewSequencer(rules ...Rule) (Sequencer, error) {
6768
s := &sequencer{}
68-
s.SetSeed(uint64(time.Now().UnixNano()))
6969
for _, rule := range append(basicRules, rules...) {
7070
rule(s)
7171
}
@@ -201,14 +201,6 @@ func (s *sequencer) Reset() {
201201
s.First()
202202
}
203203

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-
212204
// Stream sends all possible passwords in order to the given channel. If you
213205
// want to limit output, pass in a *big.Int with the number of passwords you
214206
// want to be generated and streamed.

0 commit comments

Comments
 (0)