Compare commits

..

No commits in common. "87ccc20b85c4b96fad5c53151c3a6b7a988e266c" and "e9d73d4062e024954b40ad3ec6d56467a5d0bb39" have entirely different histories.

2 changed files with 3 additions and 16 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
dist-newstyle/**
based.link

18
Main.hs
View File

@ -6,12 +6,10 @@ import System.Console.CmdArgs
import Control.Arrow
import Data.Text (pack, unpack)
import qualified Data.Text as T
import Data.Text (Text)
import qualified Data.Text.Lazy as TL
import Data.Text.Lazy.Builder (toLazyText)
import Data.Text.Encoding (decodeUtf8With, decodeUtf8, encodeUtf8)
import Data.Text.Encoding (encodeUtf8)
import Data.Maybe (fromJust, fromMaybe)
import Data.Text.Encoding.Error (lenientDecode)
import TextShow (toText)
import Text.XML.HXT.DOM.Util (hexStringToInt, intToHexString, decimalStringToInt)
import TextShow.Data.Integral (showbBin, showbOct)
@ -198,9 +196,6 @@ dec62 input =
enc62 :: String -> String
enc62 = C.unpack . BSU.fromString. Latin1.toString . (Bytes.fromByteArray . ( B62.encode64 . (intToWord64 . decimalStringToInt)))
-- enc62 :: Text -> Text
-- enc62 text = B62.text128 (fromIntegral (T.length text))
dec58 :: String -> String
-- dec58 = C.unpack . fromJust . B58.decodeBase58 . pack
dec58 input =
@ -229,7 +224,7 @@ dec16 input =
enc16 :: String -> String
enc16 = C.unpack . B16.encode . BSU.fromString
dec10 :: String -> String
dec10:: String -> String
dec10 = show . hexStringToInt
enc10 :: String -> String
@ -293,8 +288,6 @@ base64Regex = "^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$"
base58Regex = "^[1-9A-HJ-NP-Za-km-z]+$" -- incorrect
base32Regex = "^(?:[A-Z2-7]{8})*(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}=)?$"
base16Regex = "^[0-9A-FXx]*$"
base10Regex = "^[0-9]*$"
base8Regex = "^[0-7]*$"
base2Regex = "^[01]*$"
urlRegex = "^[a-zA-Z0-9%]*$"
@ -306,8 +299,6 @@ solveEnc input =
isBase58 = BSU.fromString input =~ base58Regex :: Bool
isBase32 = BSU.fromString input =~ base32Regex :: Bool
isBase16 = BSU.fromString input =~ base16Regex :: Bool
isBase10 = BSU.fromString input =~ base10Regex :: Bool
isBase8 = BSU.fromString input =~ base8Regex :: Bool
isBase2 = BSU.fromString input =~ base2Regex :: Bool
isURL = BSU.fromString input =~ urlRegex :: Bool
base91Result = if isBase91 then "\nTrying base91:\n" ++ dec91 input else ""
@ -316,11 +307,9 @@ solveEnc input =
base58Result = if isBase58 then "\nTrying base58:\n" ++ dec58 input else ""
base32Result = if isBase64 then "\nTrying base32:\n" ++ dec32 input else ""
base16Result = if isBase16 then "\nTrying base16:\n" ++ dec16 input else ""
base10Result = if isBase10 then "\nTrying base10:\n" ++ dec10 input else ""
base2Result = if isBase2 then "\nTrying base2:\n" ++ dec2 input else ""
base8Result = if isBase8 then "\nTrying base8:\n" ++ dec8 input else ""
urlResult = if isURL then "\nTrying URL decode:\n" ++ decurl input else ""
results = filter (not . null) [base91Result, base85Result, base64Result, base58Result, base32Result, base16Result, base10Result, base8Result, base2Result, urlResult]
results = filter (not . null) [base91Result, base85Result, base64Result, base58Result, base32Result, base16Result, base2Result, urlResult]
in
if null results
then "Not able to solve the encoding.\n"
@ -338,7 +327,6 @@ solveEnc input =
-- then dec32 input
-- else "Not able to solve the encoding.\n"
-- optionHandler :: EncodeOptions -> Text -> Text
optionHandler Decode{b91=True} = dec91
optionHandler Encode{b91=True} = enc91
optionHandler Decode{b85=True} = dec85