From e5530ce70c2a2f5177cdc1ede4bedab575d9b0ea Mon Sep 17 00:00:00 2001 From: whx Date: Tue, 17 May 2022 00:23:30 +0200 Subject: [PATCH] initalize --- .gitignore | 1 + CHANGELOG.md | 5 ++++ Main.hs | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ MyLib.hs | 4 +++ Setup.hs | 2 ++ based.cabal | 32 ++++++++++++++++++++ 6 files changed, 127 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 Main.hs create mode 100644 MyLib.hs create mode 100644 Setup.hs create mode 100644 based.cabal diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57fd833 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist-newstyle/** diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..258dc3f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for based + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/Main.hs b/Main.hs new file mode 100644 index 0000000..7260233 --- /dev/null +++ b/Main.hs @@ -0,0 +1,83 @@ +#!/usr/bin/env runhaskell +{-# LANGUAGE DeriveDataTypeable #-} + +module Main where +import System.Console.CmdArgs +import Control.Arrow +import qualified Data.Either.Unwrap as U +import qualified Codec.Binary.Base91 as B91 +import qualified Codec.Binary.Base85 as B85 +import qualified Codec.Binary.Base64 as B64 +import qualified Data.Word.Base62 as B62 +import qualified Codec.Binary.Base32 as B32 +import qualified Codec.Binary.Base16 as B16 +import qualified Data.Bytes as Bytes +import qualified Data.Bytes.Text.Ascii as ASCII +import Data.ByteString.UTF8 as BSU -- from utf8-string +import qualified Data.ByteString.Char8 as C + +data Based = Decode { + b91 :: Bool, + b85 :: Bool, + b64 :: Bool, + b62 :: Bool, + b32 :: Bool, + b16 :: Bool + } + | Encode { + b91 :: Bool, + b85 :: Bool, + b64 :: Bool, + b62 :: Bool, + b32 :: Bool, + b16 :: Bool + } + deriving(Show, Data, Typeable) + +-- without the show func, sequences like \n will not be shown as characters but will be executed as newline +dec91 = C.unpack . B91.decode +enc91 = B91.encode . BSU.fromString +dec85 = C.unpack . U.fromRight . B85.decode . BSU.fromString +enc85 = C.unpack . B85.encode . BSU.fromString +dec64 = C.unpack . U.fromRight . B64.decode . BSU.fromString +enc64 = C.unpack . B64.encode . BSU.fromString +dec62 = show . B62.decode64 . ASCII.fromString +enc62 = show . B62.decode64 . ASCII.fromString +dec32 = C.unpack . U.fromRight . B32.decode . BSU.fromString +enc32 = C.unpack . B32.encode . BSU.fromString +dec16 = C.unpack . U.fromRight . B16.decode . BSU.fromString +enc16 = C.unpack . B16.encode . BSU.fromString + + +optionHandler Decode{b91=True} = dec91 +optionHandler Encode{b91=True} = enc91 +optionHandler Decode{b85=True} = dec85 +optionHandler Encode{b85=True} = enc85 +optionHandler Decode{b64=True} = dec64 +optionHandler Encode{b64=True} = enc64 +optionHandler Decode{b62=True} = dec62 +optionHandler Encode{b62=True} = enc62 +optionHandler Decode{b32=True} = dec32 +optionHandler Encode{b32=True} = enc32 +optionHandler Decode{b16=True} = dec16 +optionHandler Encode{b16=True} = enc16 + +decode_ = Decode { + b91 = def &= help "decode base91", + b85 = def &= help "decode base85", + b64 = def &= help "decode base64", + b62 = def &= help "decode base62", + b32 = def &= help "decode base32", + b16 = def &= help "decode base16" + } &= help "Decode chosen base" &=auto + +encode_ = Encode { + b91 = def &= help "encode base91", + b85 = def &= help "encode base85", + b64 = def &= help "encode base64", + b62 = def &= help "encode base62", + b32 = def &= help "encode base32", + b16 = def &= help "encode base16" + } &= help "Encode chosen base" + +main = cmdArgs (modes[decode_, encode_] &= help "Anybased, when Cyberchef simply doesn't cut it. " &= program "based" &= summary "Based v0.1") >>= interact . optionHandler diff --git a/MyLib.hs b/MyLib.hs new file mode 100644 index 0000000..e657c44 --- /dev/null +++ b/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/based.cabal b/based.cabal new file mode 100644 index 0000000..085b0ac --- /dev/null +++ b/based.cabal @@ -0,0 +1,32 @@ +cabal-version: 2.4 +-- Initial package description 'based.cabal' generated by 'cabal init'. +-- For further documentation, see http://haskell.org/cabal/users-guide/ + +name: based +version: 0.1.0.0 +-- synopsis: +-- description: +-- bug-reports: +-- license: +license-file: LICENSE +-- author: +-- maintainer: +-- copyright: +-- category: +extra-source-files: CHANGELOG.md + +library + exposed-modules: MyLib + -- other-modules: + -- other-extensions: + build-depends: base ^>=4.13.0.0 + -- hs-source-dirs: + default-language: Haskell2010 + +executable based + main-is: Main.hs + other-modules: MyLib + -- other-extensions: + build-depends: base ^>=4.13.0.0, based, cmdargs, sandi, base62, base91, utf8-string, bytestring, byteslice, either-unwrap + -- hs-source-dirs: + default-language: Haskell2010