Compare commits
2 Commits
991e82cfda
...
5cf96d8ab3
Author | SHA1 | Date | |
---|---|---|---|
5cf96d8ab3 | |||
4429072e0c |
21
src/http.go
21
src/http.go
|
@ -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),
|
||||
"crt": encryptResult(crt, token),
|
||||
"key": encryptResult(key, token),
|
||||
"info": encryptResult(certInfo, token),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user