Browse Source

Take an io.Reader as the entropy source.

Yawning Angel 3 years ago
parent
commit
44425cd468
1 changed files with 3 additions and 4 deletions
  1. 3 4
      a2filter.go

+ 3 - 4
a2filter.go

@@ -17,9 +17,9 @@
 package a2filter
 
 import (
-	"crypto/rand"
 	"encoding/binary"
 	"fmt"
+	"io"
 	"math"
 	"sync"
 
@@ -51,10 +51,9 @@ type A2Filter struct {
 // postive rate p.  The actual in memory footprint of the datastructure will be
 // approximately 2^(mLn2+1) bits due to the double buffered nature of the
 // filter.
-func New(mLn2 int, p float64) (*A2Filter, error) {
+func New(rand io.Reader, mLn2 int, p float64) (*A2Filter, error) {
 	var key [16]byte
-	_, err := rand.Read(key[:])
-	if err != nil {
+	if _, err := io.ReadFull(rand, key[:]); err != nil {
 		return nil, err
 	}