diff --git a/go.mod b/go.mod index 5c868e7..2d1962e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/gin-gonic/gin v1.7.4 - github.com/jageros/hawox v0.0.6 + github.com/jageros/hawox v0.0.7 github.com/rocket049/gocui v0.3.2 gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376 ) diff --git a/go.sum b/go.sum index de57501..dfd2c79 100644 --- a/go.sum +++ b/go.sum @@ -335,8 +335,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/jackmordaunt/icns v0.0.0-20181231085925-4f16af745526/go.mod h1:UQkeMHVoNcyXYq9otUupF7/h/2tmHlhrS2zw7ZVvUqc= -github.com/jageros/hawox v0.0.6 h1:4svDUSDrss47VYJ9rd1LyZBZJHSQtcj+C88wjjYPa8k= -github.com/jageros/hawox v0.0.6/go.mod h1:Z/+N+7E3dKGvtztI4TN2uIhP/cB/7zCecT+uv3ZgCLA= +github.com/jageros/hawox v0.0.7 h1:WyX/VAoZf5JJr7LqVRSDsYLpdxnHESPEs+R0bmyd7a8= +github.com/jageros/hawox v0.0.7/go.mod h1:Z/+N+7E3dKGvtztI4TN2uIhP/cB/7zCecT+uv3ZgCLA= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= diff --git a/types/types.go b/types/types.go index 7cf9d81..7d7b5c1 100644 --- a/types/types.go +++ b/types/types.go @@ -14,6 +14,7 @@ package types import ( "encoding/json" + "github.com/jageros/hawox/rsa" "math/rand" ) @@ -46,12 +47,20 @@ func Marshal(msg *Msg) ([]byte, error) { pk.V3 = append(pk.V3, data[i+1]) } } - return json.Marshal(pk) + bts, err := json.Marshal(pk) + if err != nil { + return nil, err + } + return rsa.DefaultEncrypt(bts) } func Unmarshal(data []byte) (*Msg, error) { var pk = &pkg{} - err := json.Unmarshal(data, pk) + bts, err := rsa.DefaultDecrypt(data) + if err != nil { + return nil, err + } + err = json.Unmarshal(bts, pk) if err != nil { return nil, err }