github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/proxy/vmess/encoding/auth_test.go (about) 1 package encoding_test 2 3 import ( 4 "crypto/rand" 5 "testing" 6 7 "github.com/google/go-cmp/cmp" 8 9 "github.com/v2fly/v2ray-core/v5/common" 10 . "github.com/v2fly/v2ray-core/v5/proxy/vmess/encoding" 11 ) 12 13 func TestFnvAuth(t *testing.T) { 14 fnvAuth := new(FnvAuthenticator) 15 16 expectedText := make([]byte, 256) 17 _, err := rand.Read(expectedText) 18 common.Must(err) 19 20 buffer := make([]byte, 512) 21 b := fnvAuth.Seal(buffer[:0], nil, expectedText, nil) 22 b, err = fnvAuth.Open(buffer[:0], nil, b, nil) 23 common.Must(err) 24 if r := cmp.Diff(b, expectedText); r != "" { 25 t.Error(r) 26 } 27 }