github.com/xraypb/Xray-core@v1.8.1/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  	"github.com/xraypb/Xray-core/common"
     9  	. "github.com/xraypb/Xray-core/proxy/vmess/encoding"
    10  )
    11  
    12  func TestFnvAuth(t *testing.T) {
    13  	fnvAuth := new(FnvAuthenticator)
    14  
    15  	expectedText := make([]byte, 256)
    16  	_, err := rand.Read(expectedText)
    17  	common.Must(err)
    18  
    19  	buffer := make([]byte, 512)
    20  	b := fnvAuth.Seal(buffer[:0], nil, expectedText, nil)
    21  	b, err = fnvAuth.Open(buffer[:0], nil, b, nil)
    22  	common.Must(err)
    23  	if r := cmp.Diff(b, expectedText); r != "" {
    24  		t.Error(r)
    25  	}
    26  }