summaryrefslogtreecommitdiffhomepage
path: root/Serialization.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-15 00:26:33 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-15 00:26:41 -0400
commit4fc681f78b2e659d3db3da99fe7c640416fb3b43 (patch)
tree6d20d2864f98d4c3be1814d399bc669524ee6a42 /Serialization.hs
parentb431fc0fb9d3b4617e4331a549ea02fda236223b (diff)
downloadkeysafe-4fc681f78b2e659d3db3da99fe7c640416fb3b43.tar.gz
Change format of ~/.keysafe/backup.log
Allow deserializing SecretKeySource so we can later know what gpg keys are backed up. Converted KeyId to Text as JSON can't handle ByteString.
Diffstat (limited to 'Serialization.hs')
-rw-r--r--Serialization.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/Serialization.hs b/Serialization.hs
index eb6394c..9803d71 100644
--- a/Serialization.hs
+++ b/Serialization.hs
@@ -12,6 +12,7 @@ import Types
import Raaz.Core.Encode
import qualified Data.ByteString as B
import qualified Data.ByteString.UTF8 as BU8
+import qualified Data.Text as T
import Data.Monoid
import Data.Word
@@ -19,7 +20,7 @@ import Data.Word
-- For example "gpg C910D9222512E3C7", or "file path".
instance Encodable SecretKeySource where
toByteString (GpgKey (KeyId b)) =
- "gpg" <> B.singleton sepChar <> b
+ "gpg" <> B.singleton sepChar <> BU8.fromString (T.unpack b)
toByteString (KeyFile f) =
"file" <> B.singleton sepChar <> BU8.fromString f
fromByteString b = case B.break (== sepChar) b of
@@ -28,7 +29,7 @@ instance Encodable SecretKeySource where
| otherwise ->
let i = B.drop 1 rest
in case t of
- "gpg" -> Just $ GpgKey (KeyId i)
+ "gpg" -> Just $ GpgKey (KeyId (T.pack (BU8.toString i)))
"file" -> Just $ KeyFile (BU8.toString i)
_ -> Nothing