42 lines
920 B
Go
42 lines
920 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func Test_Load(t *testing.T) {
|
|
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"))
|
|
}
|
|
|
|
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)
|
|
}
|