diff options
author | joe <joe@jerkface.net> | 2017-10-13 16:35:02 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-10-13 16:35:02 -0400 |
commit | f1a79aef9799176b52efb6197aaf7c2b5a8f14ad (patch) | |
tree | feb8727a39d3170f2b60a771c620ab3600199add /src/Crypto/Tox.hs | |
parent | b5df42236969b38bbddcc47cb5cbfdc94a7d3393 (diff) |
Show rendezvous addresses for toxid search results.
Diffstat (limited to 'src/Crypto/Tox.hs')
-rw-r--r-- | src/Crypto/Tox.hs | 6 |
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) |
58 | import Data.ByteString as B | 58 | import Data.ByteString as B |
59 | import qualified Data.ByteString.Base16 as Base16 | 59 | import qualified Data.ByteString.Base16 as Base16 |
60 | import qualified Data.ByteString.Base64 as Base64 | ||
60 | import qualified Data.ByteString.Char8 as C8 | 61 | import qualified Data.ByteString.Char8 as C8 |
61 | import Data.Data | 62 | import Data.Data |
62 | import Data.Functor.Contravariant | 63 | import Data.Functor.Contravariant |
@@ -252,6 +253,9 @@ quoted shows s = '"':shows ('"':s) | |||
252 | bin2hex :: ByteArrayAccess bs => bs -> String | 253 | bin2hex :: ByteArrayAccess bs => bs -> String |
253 | bin2hex = C8.unpack . Base16.encode . BA.convert | 254 | bin2hex = C8.unpack . Base16.encode . BA.convert |
254 | 255 | ||
256 | bin2base64 :: ByteArrayAccess bs => bs -> String | ||
257 | bin2base64 = C8.unpack . Base64.encode . BA.convert | ||
258 | |||
255 | instance Show Nonce24 where | 259 | instance 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 | ||
290 | instance Show Nonce32 where | 294 | instance Show Nonce32 where |
291 | showsPrec d nonce = quoted (mappend $ bin2hex nonce) | 295 | showsPrec d nonce = mappend $ bin2base64 nonce |
292 | 296 | ||
293 | instance Serialize Nonce32 where | 297 | instance Serialize Nonce32 where |
294 | get = Nonce32 <$> getBytes 32 | 298 | get = Nonce32 <$> getBytes 32 |