Skip to content

Commit

Permalink
Support pretty-printing for SignedMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Dec 20, 2021
1 parent 15f7cfb commit 4052eed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Protocol/SignedMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,13 @@ public function setMeta($key, $value)
}

/**
* @param bool $pretty
* @return string
* @throws SodiumException
*/
public function toString()
public function toString($pretty = false)
{
$code = $pretty ? JSON_PRETTY_PRINT : 0;
return (string) json_encode(array(
'signature' => sodium_bin2base64(
Util::rawBinary($this->message->getSignature(), 64),
Expand All @@ -161,7 +163,7 @@ public function toString()
'message' => $this->message->getContents(),
'provider' => $this->provider,
'public-key' => $this->publicKey
));
), $code);
}

/**
Expand Down

0 comments on commit 4052eed

Please sign in to comment.