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

     1  package encrypt
     2  
     3  import "testing"
     4  
     5  func TestAES256CFBMethod_Encrypt(t *testing.T) {
     6  	method, err := NewMethodInstance("aes-256-cfb", "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  }
    24  
    25  func TestAES256CFBMethod_Encrypt2(t *testing.T) {
    26  	method, err := NewMethodInstance("aes-256-cfb", "abc", "123")
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  	src := []byte("Hello, World")
    31  	dst, err := method.Encrypt(src)
    32  	if err != nil {
    33  		t.Fatal(err)
    34  	}
    35  	t.Log("dst:", string(dst))
    36  
    37  	src, err = method.Decrypt(dst)
    38  	if err != nil {
    39  		t.Fatal(err)
    40  	}
    41  	t.Log("src:", string(src))
    42  }