Files
encryptx/aesx/aesx_test.go
T

37 lines
808 B
Go
Raw Normal View History

2023-12-27 19:00:14 +08:00
package aesx_test
import (
"fmt"
"testing"
"code.yun.ink/pkg/encryptx/aesx"
)
func TestAes(t *testing.T) {
key := "example key 1234"
plaintext := "exampleplaintext"
2024-03-15 13:49:58 +08:00
// aesx.AesEncrypt(plaintext,key)
// aesx.AesDecrypt()
2023-12-27 19:00:14 +08:00
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)
}
2024-03-15 13:49:58 +08:00
func TestDemo(t *testing.T) {
c := []byte("08I2GfoqfIlUYgteelimxQ")
c := []byte("rRq++jXDMPDVcUkXAZA9kg==:o57DgQ+iQMXpERuShWs/XA==")
a,e := aesx.AesDecrypt(c, k)
fmt.Println(a,e)
}