From 9bff4cef2684c85b86738712852ebb4994b9e2de Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Thu, 2 Sep 2021 16:18:36 -0700 Subject: [PATCH] Update Overlay Message to use Explictly Hex Encoded Strings --- functionality/filesharing/filesharing_functionality.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functionality/filesharing/filesharing_functionality.go b/functionality/filesharing/filesharing_functionality.go index fe5c3cf..a034302 100644 --- a/functionality/filesharing/filesharing_functionality.go +++ b/functionality/filesharing/filesharing_functionality.go @@ -6,6 +6,7 @@ import ( "cwtch.im/cwtch/model/attr" "cwtch.im/cwtch/peer" "cwtch.im/cwtch/protocol/files" + "encoding/hex" "encoding/json" "errors" "fmt" @@ -32,8 +33,8 @@ func FunctionalityGate(experimentMap map[string]bool) (*Functionality, error) { // This is the format that the UI will parse to display the message type OverlayMessage struct { Name string `json:"f"` - Hash []byte `json:"h"` - Nonce []byte `json:"n"` + Hash string `json:"h"` + Nonce string `json:"n"` Size uint64 `json:"s"` } @@ -58,10 +59,11 @@ func (f *Functionality) ShareFile(filepath string, profile peer.CwtchPeer, handl return err } + message := OverlayMessage{ Name: path.Base(manifest.FileName), - Hash: manifest.RootHash, - Nonce: nonce[:], + Hash: hex.EncodeToString(manifest.RootHash), + Nonce: hex.EncodeToString(nonce[:]), Size: manifest.FileSizeInBytes, }