26 lines
570 B
Go
26 lines
570 B
Go
package aesx_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"code.yun.ink/open/utils/encryptx/aesx"
|
|
)
|
|
|
|
func TestAes(t *testing.T) {
|
|
key := "example key 1234"
|
|
plaintext := "exampleplaintext"
|
|
ciphertext, err := aesx.AESCBCEncrypt(key, plaintext)
|
|
fmt.Println(ciphertext, err)
|
|
|
|
plaintext, err = aesx.AESCBCDecrypter(key, ciphertext)
|
|
fmt.Println(plaintext, err)
|
|
///GCM
|
|
noncetext := ""
|
|
ciphertext, noncetext, err = aesx.AESGCMEncrypt(key, plaintext)
|
|
fmt.Println(ciphertext, err)
|
|
|
|
plaintext, err = aesx.AESGCMDecrypter(key, ciphertext, noncetext)
|
|
fmt.Println(plaintext, err)
|
|
}
|