From 4ed990981e5bf0b3902364b6b09919d3d7d976cc Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Tue, 16 Jul 2019 11:24:51 -0400 Subject: String to KeyGrip utility. --- lib/KeyDB.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/KeyDB.hs b/lib/KeyDB.hs index 5e74ea4..0bc0fb3 100644 --- a/lib/KeyDB.hs +++ b/lib/KeyDB.hs @@ -10,6 +10,8 @@ module KeyDB , kkData , lookupKeyData , lookupByGrip + , fingerprintGrip + , smallprGrip , transmute , transmuteAt , alterKeyDB @@ -37,6 +39,7 @@ import Data.Maybe import Data.OpenPGP import Data.Ord import Foreign.Storable +import Text.Read import Data.List.Merge import Data.OpenPGP.Util @@ -68,6 +71,9 @@ fingerprintGrip (Fingerprint bs) = case decode $ L.fromStrict $ S.drop (S.length bs - sizeOf (0::Int)) bs of i -> KeyInt i +smallprGrip :: String -> Maybe KeyGrip +smallprGrip pr = KeyInt <$> readMaybe ("0x" ++ drop (length pr - 2 * sizeOf (0::Int)) pr) + data KeyDB = KeyDB { byKeyKey :: Map.Map KeyKey KeyData , byGrip :: IMap KeyGrip [KeyKey] -- cgit v1.2.3