25 lines
560 B
Go
25 lines
560 B
Go
|
|
package aesx_test
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"testing"
|
||
|
|
"yunink/app/pkg/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)
|
||
|
|
}
|