summaryrefslogtreecommitdiff
path: root/src/Crypto/Tox.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-10-13 16:35:02 -0400
committerjoe <joe@jerkface.net>2017-10-13 16:35:02 -0400
commitf1a79aef9799176b52efb6197aaf7c2b5a8f14ad (patch)
treefeb8727a39d3170f2b60a771c620ab3600199add /src/Crypto/Tox.hs
parentb5df42236969b38bbddcc47cb5cbfdc94a7d3393 (diff)
Show rendezvous addresses for toxid search results.
Diffstat (limited to 'src/Crypto/Tox.hs')
-rw-r--r--src/Crypto/Tox.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs
index 6660fc13..c8b3665f 100644
--- a/src/Crypto/Tox.hs
+++ b/src/Crypto/Tox.hs
@@ -57,6 +57,7 @@ import qualified Data.ByteArray as BA
57 ;import Data.ByteArray as BA (ByteArrayAccess, Bytes) 57 ;import Data.ByteArray as BA (ByteArrayAccess, Bytes)
58import Data.ByteString as B 58import Data.ByteString as B
59import qualified Data.ByteString.Base16 as Base16 59import qualified Data.ByteString.Base16 as Base16
60import qualified Data.ByteString.Base64 as Base64
60import qualified Data.ByteString.Char8 as C8 61import qualified Data.ByteString.Char8 as C8
61import Data.Data 62import Data.Data
62import Data.Functor.Contravariant 63import Data.Functor.Contravariant
@@ -252,6 +253,9 @@ quoted shows s = '"':shows ('"':s)
252bin2hex :: ByteArrayAccess bs => bs -> String 253bin2hex :: ByteArrayAccess bs => bs -> String
253bin2hex = C8.unpack . Base16.encode . BA.convert 254bin2hex = C8.unpack . Base16.encode . BA.convert
254 255
256bin2base64 :: ByteArrayAccess bs => bs -> String
257bin2base64 = C8.unpack . Base64.encode . BA.convert
258
255instance Show Nonce24 where 259instance Show Nonce24 where
256 showsPrec d nonce = quoted (mappend $ bin2hex nonce) 260 showsPrec d nonce = quoted (mappend $ bin2hex nonce)
257 261
@@ -288,7 +292,7 @@ newtype Nonce32 = Nonce32 ByteString
288 deriving (Eq, Ord, ByteArrayAccess, Data) 292 deriving (Eq, Ord, ByteArrayAccess, Data)
289 293
290instance Show Nonce32 where 294instance Show Nonce32 where
291 showsPrec d nonce = quoted (mappend $ bin2hex nonce) 295 showsPrec d nonce = mappend $ bin2base64 nonce
292 296
293instance Serialize Nonce32 where 297instance Serialize Nonce32 where
294 get = Nonce32 <$> getBytes 32 298 get = Nonce32 <$> getBytes 32