1 -- This file is part of htalkat
2 -- Copyright (C) 2021 Martin Bays <mbays@sdf.org>
4 -- This program is free software: you can redistribute it and/or modify
5 -- it under the terms of version 3 of the GNU General Public License as
6 -- published by the Free Software Foundation, or any later version.
8 -- You should have received a copy of the GNU General Public License
9 -- along with this program. If not, see http://www.gnu.org/licenses/.
13 module Fingerprint
where
15 import Control
.Monad
(guard)
17 import qualified Data
.ByteString
as BS
21 -- | 16-byte SHA256/128 fingerprint
22 newtype Fingerprint
= Fingerprint BS
.ByteString
23 deriving (Eq
,Ord
,Show)
25 parseFingerprint
:: String -> Maybe Fingerprint
26 parseFingerprint s
= do
27 guard $ length s
== 32
28 Fingerprint
<$> parseHexString s
30 showFingerprint
:: Fingerprint
-> String
31 showFingerprint
(Fingerprint fp
) = showHexString fp