Compare commits

..

No commits in common. "master" and "v0.1.4" have entirely different histories.

15
sign.go
View File

@ -21,11 +21,6 @@ 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
@ -56,7 +51,7 @@ func (tc TokenCoder) SeedHex() string {
}
func Format(token string) (txt string, err error) {
var tp tokenPrint
var payload interface{}
var data []byte
data, err = b64.DecodeString(strings.TrimFunc(token, trim))
if err != nil {
@ -79,14 +74,16 @@ func Format(token string) (txt string, err error) {
return
}
tp.Signature = hex.EncodeToString(td.Signature)
buf.Reset()
buf.Write(td.Payload)
err = dec.Decode(&tp.Payload)
err = dec.Decode(&payload)
buf.Reset()
buf.Write([]byte("SIGNATURE=" + hex.EncodeToString(td.Signature) + "\n"))
enc := codec.NewEncoder(buf, &jHandle)
err = enc.Encode(tp)
err = enc.Encode(payload)
txt = buf.String()
return
}