From f0545cde7b63171a13561a20da0cf7287eac8842 Mon Sep 17 00:00:00 2001 From: Naveen Mahalingam Date: Sat, 20 Apr 2024 09:28:49 -0700 Subject: [PATCH] password sequencer documentation --- password/sequencer.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/password/sequencer.go b/password/sequencer.go index 4dacfc2..5db581e 100644 --- a/password/sequencer.go +++ b/password/sequencer.go @@ -6,7 +6,6 @@ import ( "math/big" "math/rand/v2" "sync" - "time" ) var ( @@ -14,6 +13,10 @@ var ( biOne = big.NewInt(1) ) +// Sequencer is a deterministic Password Generator that generates all possible +// combinations of passwords for a Charset and defined number of characters in +// the password. It lets you move back and forth through the list of possible +// passwords, and involves no RNG. type Sequencer interface { // First moves to the first possible password and returns the same. First() string @@ -37,8 +40,6 @@ type Sequencer interface { PrevN(n *big.Int) string // Reset cleans up state and moves to the first possible word. Reset() - // SetSeed overrides the seed value for the RNG. - SetSeed(seed uint64) // Stream sends all possible passwords in order to the given channel. If you // want to limit output, pass in a *big.Int with the number of passwords you // want to be generated and streamed. @@ -65,7 +66,6 @@ type sequencer struct { // interface. func NewSequencer(rules ...Rule) (Sequencer, error) { s := &sequencer{} - s.SetSeed(uint64(time.Now().UnixNano())) for _, rule := range append(basicRules, rules...) { rule(s) } @@ -201,14 +201,6 @@ func (s *sequencer) Reset() { s.First() } -// SetSeed changes the seed value of the RNG. -func (s *sequencer) SetSeed(seed uint64) { - s.mutex.Lock() - defer s.mutex.Unlock() - - s.rng = rand.New(rand.NewPCG(seed, seed+100)) -} - // Stream sends all possible passwords in order to the given channel. If you // want to limit output, pass in a *big.Int with the number of passwords you // want to be generated and streamed.