Safe Haskell | None |
---|---|
Language | Haskell2010 |
Translate between binary data and a human-readable collection of words.
Synopsis
- toText :: ByteString -> Text
- fromText :: Text -> Either TranslationError ByteString
- data TranslationError
Documentation
toText :: ByteString -> Text Source #
Inverse of fromText
, modulo whitespace count.
>>>
toText (BSL.pack [104, 101, 108, 108, 111])
"frighten glossary glucose handiwork gremlin"
fromText :: Text -> Either TranslationError ByteString Source #
Convert a text of whitespace-separated words to their binary
representation. The whitespace splitting behaviour is given by words
.
>>>
fromText (T.pack "frighten glossary glucose handiwork gremlin")
Right "hello"
Invalid words are recognized:
>>>
fromText (T.pack "frighten dragon glucose handiwork gremlin")
Left (BadWord "dragon")
Typical mistakes include accidentally swapping numbers, which leads to a parity error:
>>>
fromText (T.pack "frighten glucose glossary handiwork gremlin")
Left (BadParity "glucose" 108)
data TranslationError Source #
Possible translation errors from a list of PGP words to binary format.
BadWord Text | Word is not recognized |
BadParity Text Word8 | Word is recognized, but from the wrong alphabet. Duplicates, omissions, and neighbour transpositions are often cause for this. |
Instances
Eq TranslationError Source # | |
Defined in Data.Text.PgpWordlist.Internal.Types (==) :: TranslationError -> TranslationError -> Bool # (/=) :: TranslationError -> TranslationError -> Bool # | |
Ord TranslationError Source # | |
Defined in Data.Text.PgpWordlist.Internal.Types compare :: TranslationError -> TranslationError -> Ordering # (<) :: TranslationError -> TranslationError -> Bool # (<=) :: TranslationError -> TranslationError -> Bool # (>) :: TranslationError -> TranslationError -> Bool # (>=) :: TranslationError -> TranslationError -> Bool # max :: TranslationError -> TranslationError -> TranslationError # min :: TranslationError -> TranslationError -> TranslationError # | |
Show TranslationError Source # | |
Defined in Data.Text.PgpWordlist.Internal.Types showsPrec :: Int -> TranslationError -> ShowS # show :: TranslationError -> String # showList :: [TranslationError] -> ShowS # |