Compare commits

...

2 Commits

Author SHA1 Message Date
5cf96d8ab3 list 2024-10-31 11:51:34 +08:00
4429072e0c list 2024-10-31 10:45:46 +08:00
2 changed files with 26 additions and 4 deletions

View File

@ -35,10 +35,11 @@ func domainList(c *gin.Context) {
log.Fatal(err)
}
encryptData := encryptResult(string(data), token)
c.JSON(200, gin.H{
"code": 200,
"msg": "Success",
"data": encryptResult(string(data), token),
"msg": "success",
"data": encryptData,
})
}
@ -78,12 +79,24 @@ func getCert(c *gin.Context) {
}
key := string(keyContent)
certInfoFilePath := path.Join(dir, CertInfoFileName)
certInfoContent, err := os.ReadFile(certInfoFilePath)
if err != nil {
c.JSON(200, gin.H{
"code": 500,
"msg": "Failed to read cert info file.",
})
return
}
certInfo := string(certInfoContent)
c.JSON(200, gin.H{
"code": 200,
"msg": "Success",
"data": gin.H{
"crt": encryptResult(crt, token),
"key": encryptResult(key, token),
"info": encryptResult(certInfo, token),
},
})
}

View File

@ -61,3 +61,12 @@ func TestRSA(t *testing.T) {
fmt.Println(string(decryptd))
}
func TestAES(t *testing.T) {
content := "123456"
encryptd := crypto.EncryptAES([]byte("12345678901234561234567890123456"), []byte(content))
fmt.Println(base64.StdEncoding.EncodeToString(encryptd))
plain := crypto.DecryptAES([]byte("12345678901234561234567890123456"), encryptd)
fmt.Println(string(plain))
}