package helper
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func Test_EncryptAES(t *testing.T) {
|
|
|
|
// 要加密的明文
|
|
str := `{"open_id":"op2kh5PTc2-4u3XaADjjbkxeXPn0","userName":"山野雾灯"}`
|
|
// 密钥,AES 支持 16、24 或 32 字节的密钥
|
|
key := "0123456789abcdef0123456789abcdef"
|
|
ret, err := EncryptAES(str, key)
|
|
t.Log(err)
|
|
t.Log(ret)
|
|
res, err := DecryptAES(ret, key)
|
|
t.Log(err)
|
|
t.Log(string(res))
|
|
|
|
}
|