-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys_test.go
38 lines (35 loc) · 878 Bytes
/
keys_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package krypto431
import (
"testing"
)
var (
/*
shortTestKey = &Key{
Id: []rune("UGXLV"),
Runes: []rune("IKWZHPUXQXDNYWTCPKIVLVGWBKGRJYTWQDDPKLYIMSSHYQXOLLIBAOXTZGBCQLYEXCLZKRVTLXEZULTEJKUAERIOXVHIGXJEFIWF"),
}
*/
)
func TestGenerateKeys(t *testing.T) {
keySize := 1000
k := New(WithKeyLength(keySize))
t.Log("Generating...")
err := k.GenerateKeys(100, nil)
if err != nil {
t.Fatal(err)
}
for _, key := range k.Keys {
if len(key.Runes) != keySize {
t.Errorf("Key is %d runes long, wanted %d", len(key.Runes), keySize)
}
if len(key.Id) != k.GroupSize {
t.Errorf("KeyId is not the group size (wanted %d, got %d)", k.GroupSize, len(key.Id))
}
for _, b := range key.Runes {
if !(b >= 'A' && b <= 'Z') {
t.Error("Key letters are not between A and Z")
}
}
t.Logf("OK, here is key id %s: %s", string(key.Id), string(key.Runes))
}
}