mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-06 06:40:25 +08:00
对边缘节点配置缓存进行加密,提升安全性
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user