Safe Haskell | None |
---|---|
Language | Haskell2010 |
Core functionality for conversion between binary formats and PGP word lists.
Synopsis
- toText :: ByteString -> Text
- fromText :: Text -> Either TranslationError ByteString
- toEvenWord :: Word8 -> EvenWord
- toOddWord :: Word8 -> OddWord
- fromEvenWord :: Text -> Either TranslationError Word8
- fromOddWord :: Text -> Either TranslationError Word8
- lookupEvenOdd :: Text -> (Maybe Word8, Maybe Word8)
- evenMap :: Word8Bimap EvenWord
- oddMap :: Word8Bimap OddWord
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)
toEvenWord :: Word8 -> EvenWord Source #
Look up the word corresponding to a byte.
fromEvenWord :: Text -> Either TranslationError Word8 Source #
Simple conversion, taking into account invalid words.
fromOddWord :: Text -> Either TranslationError Word8 Source #
Simple conversion, taking into account invalid words.