added usable dec85

This commit is contained in:
Stefan Friese 2024-04-29 23:06:06 +02:00
parent 68eb560810
commit d3289e0997
1 changed files with 8 additions and 14 deletions

22
Main.hs
View File

@ -115,24 +115,18 @@ octToInt (x : xs) = x + 8 * octToInt xs
dec91 :: String -> String
dec91 = C.unpack . B91.decode
-- dec91 :: String -> String
-- dec91 input =
-- case B91.decode (C.pack input) of
-- Right decoded -> C.unpack decoded
-- Left errMsg -> "Error: " ++ errMsg
-- decoded | C.null decoded -> Left "Failed to decode from Base91"
-- | otherwise -> Right (C.unpack decoded)
enc91 :: String -> String
enc91 = B91.encode . BSU.fromString
-- enc91 :: String -> Either String String
-- enc91 input =
-- case B91.encode (BSU.fromString input) of
-- encoded | C.null encoded -> Left "Failed to encode to Base91"
-- | otherwise -> Right (C.unpack encoded)
-- dec85 = C.unpack . U.fromRight . B85.decode . BSU.fromString
dec85 :: String -> String
dec85 input =
let decoded = B85.decode (BSU.fromString input)
in case decoded of
Right decodedStr -> C.unpack decodedStr
Left (decodedStr, _) -> C.unpack decodedStr
dec85 = C.unpack . U.fromRight . B85.decode . BSU.fromString
enc85 :: String -> String
enc85 = C.unpack . B85.encode . BSU.fromString
-- dec64 = C.unpack . B64L.decodeLenient . BSU.fromString