对边缘节点配置缓存进行加密,提升安全性

This commit is contained in:
刘祥超
2023-03-02 10:28:15 +08:00
parent 4379acbeea
commit a068ce9a4f
3 changed files with 110 additions and 13 deletions

View File

@@ -7,8 +7,8 @@ import (
"testing"
)
func TestEncryptData(t *testing.T) {
e, err := EncryptData("a", "b", maps.Map{
func TestEncryptMap(t *testing.T) {
e, err := EncryptMap("a", "b", maps.Map{
"c": 1,
}, 5)
if err != nil {
@@ -16,16 +16,30 @@ func TestEncryptData(t *testing.T) {
}
t.Log("e:", e)
s, err := DecryptData("a", "b", e)
s, err := DecryptMap("a", "b", e)
if err != nil {
t.Fatal(err)
}
t.Log("s:", s)
}
func TestEncryptData(t *testing.T) {
encoded, err := EncryptData("a", "b", []byte("Hello, World"))
if err != nil {
t.Fatal(err)
}
t.Log("encoded:", encoded)
source, err := DecryptData("a", "b", encoded)
if err != nil {
t.Fatal(err)
}
t.Log("source:", string(source))
}
func BenchmarkEncryptData(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = EncryptData("a", "b", maps.Map{
_, _ = EncryptMap("a", "b", maps.Map{
"c": 1,
}, 5)
}