封装的方法类
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user