plugin/utils/utils_test.go

42 lines
920 B
Go
Raw Permalink Normal View History

2024-08-30 18:02:15 +08:00
package utils
import (
"fmt"
"testing"
)
2024-11-14 18:33:56 +08:00
func Test_Load(t *testing.T) {
2024-08-30 18:02:15 +08:00
got, err := Load("../../pkg")
if err != nil {
t.Errorf("load() error = %v", err)
return
}
fmt.Printf("%v \n", got)
fmt.Printf("%v \n", got[0])
}
func Test_BuildPem(t *testing.T) {
pri := NewPrivate(WithPemPriHeader(PemPrivateKHeader), WithPemPriFooter(PemPrivateKFooter))
t.Logf("\n%s", pri.Build("pri key 123456"))
puk := NewPublic(WithPemPukHeader(PemPublicHeader), WithPemPukFooter(PemPublicPuFooter))
t.Logf("\n%s", puk.Build("puk key 123456"))
pri2 := NewPrivate()
t.Logf("\n%s", pri2.Build("pri key"))
puk2 := NewPublic()
t.Logf("\n%s", puk2.Build("puk key"))
}
2024-11-14 18:33:56 +08:00
func Test_AesDecode(t *testing.T) {
key := "837c7a898810160ce5aab4c42bf22bc4"
encStr := ""
str, err := AesDecode(encStr, []byte(key))
if err != nil {
t.Errorf("AesDecode() error = %v", err)
return
}
t.Logf("encStr: %s, str: %s", encStr, str)
}