char mins done; need to shuffle some error condition checks before
This commit is contained in:
27
pwgenerator/funcs_cryptoshuffer.go
Normal file
27
pwgenerator/funcs_cryptoshuffer.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package pwgenerator
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
)
|
||||
|
||||
// Int63 is used to interface as a *(math/rand).Rand but backed with a cryptographically sound generation.
|
||||
func (c *cryptoShuffler) Int63() (i int64) {
|
||||
|
||||
var b [8]byte
|
||||
|
||||
_, _ = rand.Read(b[:])
|
||||
|
||||
// Mask is used to ensure a positive number.
|
||||
i = int64(binary.LittleEndian.Uint64(b[:]) & (1<<63 - 1))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Seed is used to interface as a *(math/rand).Rand.
|
||||
func (c *cryptoShuffler) Seed(_ int64) {
|
||||
|
||||
// It's 100% OK that this is a no-op because we seed from the crypto methodology itself within cryptoShuffler.Int63 on each call.
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user