1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-13 13:40:30 +08:00
Files
WireGold/gold/link/crypto_test.go
2023-08-04 13:48:46 +08:00

25 lines
365 B
Go

package link
import (
"bytes"
"crypto/rand"
"testing"
)
func TestXOR(t *testing.T) {
m := Me{
mask: 0x12345678_90abcdef,
}
buf := make([]byte, 65535)
for i := 1; i < 65536; i++ {
data := buf[:i]
_, err := rand.Read(data)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(m.xor(m.xor(data)), data) {
t.Fatal("unexpected xor at ", i)
}
}
}