github.com/TeaOSLab/EdgeNode@v1.3.8/internal/encrypt/method_raw_test.go (about)

     1  package encrypt
     2  
     3  import "testing"
     4  
     5  func TestRawMethod_Encrypt(t *testing.T) {
     6  	method, err := NewMethodInstance("raw", "abc", "123")
     7  	if err != nil {
     8  		t.Fatal(err)
     9  	}
    10  	src := []byte("Hello, World")
    11  	dst, err := method.Encrypt(src)
    12  	if err != nil {
    13  		t.Fatal(err)
    14  	}
    15  	dst = dst[:len(src)]
    16  	t.Log("dst:", string(dst))
    17  
    18  	src, err = method.Decrypt(dst)
    19  	if err != nil {
    20  		t.Fatal(err)
    21  	}
    22  	t.Log("src:", string(src))
    23  }