bump 0.1.2.5
[htalkat.git] / Fingerprint.hs
blob7bff0b4151c7d7d1c1fff83d496db325f1ce54e2
1 -- This file is part of htalkat
2 -- Copyright (C) 2021 Martin Bays <mbays@sdf.org>
3 --
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.
7 --
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/.
11 {-# LANGUAGE Safe #-}
13 module Fingerprint where
15 import Control.Monad (guard)
17 import qualified Data.ByteString as BS
19 import HexString
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