diff --git a/sign.go b/sign.go index 4b572c1..65b88a9 100644 --- a/sign.go +++ b/sign.go @@ -21,6 +21,11 @@ type tokenData struct { Payload []byte `codec:"p"` } +type tokenPrint struct { + Signature string `codec:"signature"` + Payload interface{} `codec:"payload"` +} + type TokenCoder struct { valid bool privKey ed25519.PrivateKey @@ -51,7 +56,7 @@ func (tc TokenCoder) SeedHex() string { } func Format(token string) (txt string, err error) { - var payload interface{} + var tp tokenPrint var data []byte data, err = b64.DecodeString(strings.TrimFunc(token, trim)) if err != nil { @@ -74,16 +79,14 @@ func Format(token string) (txt string, err error) { return } + tp.Signature = hex.EncodeToString(td.Signature) buf.Reset() buf.Write(td.Payload) - err = dec.Decode(&payload) - + err = dec.Decode(&tp.Payload) buf.Reset() - buf.Write([]byte("SIGNATURE=" + hex.EncodeToString(td.Signature) + "\n")) - enc := codec.NewEncoder(buf, &jHandle) - err = enc.Encode(payload) + err = enc.Encode(tp) txt = buf.String() return }