summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/hamming.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/hamming.go b/lib/hamming.go
index c267c43..b2c46e9 100644
--- a/lib/hamming.go
+++ b/lib/hamming.go
@@ -3,6 +3,12 @@
package lib
+import "math/rand"
+
+func init() {
+ rand.Seed(42)
+}
+
func HammingDistance(a, b string) int {
if len(a) != len(b) {
return -1 // Fail.
@@ -25,3 +31,11 @@ func setBits(b byte) int {
}
return int(c)
}
+
+// Generates a key of size 'size' bytes.
+func genKey(size int) []byte {
+ bs := make([]byte, size, size)
+ rand.Read(bs)
+
+ return bs
+}