added URI encoding
This commit is contained in:
parent
3d7f981bde
commit
6d37b57b97
9
Main.hs
9
Main.hs
|
@ -17,6 +17,7 @@ import qualified Codec.Binary.Base91 as B91
|
|||
import qualified Codec.Binary.Base85 as B85
|
||||
import qualified Codec.Binary.Base64 as B64
|
||||
import qualified Codec.Binary.Base64Url as B64U
|
||||
import qualified Network.HTTP.Base as HB
|
||||
import qualified Data.Word.Base62 as B62
|
||||
import qualified Haskoin.Address.Base58 as B58
|
||||
import qualified Codec.Binary.Base32 as B32
|
||||
|
@ -36,6 +37,7 @@ data Based = Decode {
|
|||
b85 :: Bool,
|
||||
b64 :: Bool,
|
||||
b64url :: Bool,
|
||||
url :: Bool,
|
||||
b62 :: Bool,
|
||||
b58 :: Bool,
|
||||
b32 :: Bool,
|
||||
|
@ -53,6 +55,7 @@ data Based = Decode {
|
|||
b85 :: Bool,
|
||||
b64 :: Bool,
|
||||
b64url :: Bool,
|
||||
url :: Bool,
|
||||
b62 :: Bool,
|
||||
b58 :: Bool,
|
||||
b32 :: Bool,
|
||||
|
@ -86,6 +89,8 @@ dec64 = C.unpack . U.fromRight . B64.decode . BSU.fromString
|
|||
enc64 = C.unpack . B64.encode . BSU.fromString
|
||||
dec64url = C.unpack . U.fromRight . B64U.decode . BSU.fromString
|
||||
enc64url = C.unpack . B64U.encode . BSU.fromString
|
||||
decurl = HB.urlDecode
|
||||
encurl = HB.urlEncode
|
||||
dec62 = show . fromJust . B62.decode128 . (Bytes.fromByteString . BSU.fromString)
|
||||
enc62 = C.unpack . BSU.fromString. Bytes.toLatinString . (Bytes.fromByteArray . ( B62.encode64 . (intToWord64 . decimalStringToInt)))
|
||||
dec58 = C.unpack . fromJust . B58.decodeBase58 . pack
|
||||
|
@ -117,6 +122,8 @@ optionHandler Decode{b64=True} = dec64
|
|||
optionHandler Encode{b64=True} = enc64
|
||||
optionHandler Decode{b64url=True} = dec64url
|
||||
optionHandler Encode{b64url=True} = enc64url
|
||||
optionHandler Decode{url=True} = decurl
|
||||
optionHandler Encode{url=True} = encurl
|
||||
optionHandler Decode{b62=True} = dec62
|
||||
optionHandler Encode{b62=True} = enc62
|
||||
optionHandler Decode{b58=True} = dec58
|
||||
|
@ -145,6 +152,7 @@ decode_ = Decode {
|
|||
b85 = def &= help "decode base85",
|
||||
b64 = def &= help "decode base64",
|
||||
b64url = def &= help "decode base64Url",
|
||||
url = def &= help "decode URI",
|
||||
b62 = def &= help "decode base62",
|
||||
b58 = def &= help "decode base58",
|
||||
b32 = def &= help "decode base32",
|
||||
|
@ -163,6 +171,7 @@ encode_ = Encode {
|
|||
b85 = def &= help "encode base85",
|
||||
b64 = def &= help "encode base64",
|
||||
b64url = def &= help "encode base64Url",
|
||||
url = def &= help "encode URI",
|
||||
b62 = def &= help "encode base62",
|
||||
b58 = def &= help "encode base58",
|
||||
b32 = def &= help "encode base32",
|
||||
|
|
26
README.md
26
README.md
|
@ -2,9 +2,10 @@
|
|||
|
||||
A commandline tool that lets you encode and decode most of the bases.
|
||||
|
||||
Release binary is statically linked via
|
||||
Release binary is statically linked and stripped via
|
||||
```sh
|
||||
cabal v2-build --enable-executable-static -O2
|
||||
strip --strip-all based
|
||||
```
|
||||
|
||||
## Compilation
|
||||
|
@ -32,4 +33,27 @@ echo '>OwJh>}AQ;r@@Y?FF' | based --b91
|
|||
Hello, World!
|
||||
```
|
||||
|
||||
## What is Transcoded?
|
||||
|
||||
The following are the supported encodings
|
||||
* Base91
|
||||
* Base85
|
||||
* Base64
|
||||
* Base64url
|
||||
* URI Encoding
|
||||
* Base62
|
||||
* Base58
|
||||
* Base32
|
||||
* Quoted-Printable
|
||||
* UU Encoding
|
||||
* XX Encoding
|
||||
* yEncoding
|
||||
* Char to Hex and vice versa
|
||||
* Decimal to Hex and vice versa
|
||||
* Oktal to Hex
|
||||
* Binary to Hex and vice versa
|
||||
qp
|
||||
uu
|
||||
xx
|
||||
yenc
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ cabal-version: 2.4
|
|||
-- For further documentation, see http://haskell.org/cabal/users-guide/
|
||||
|
||||
name: based
|
||||
version: 0.4.0.0
|
||||
version: 0.4.1.0
|
||||
-- synopsis:
|
||||
-- description:
|
||||
-- bug-reports:
|
||||
|
@ -27,6 +27,6 @@ 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, text-show, hxt,haskoin-core, text, bytes, cborg, text-latin1
|
||||
build-depends: base ^>=4.13.0.0, based, cmdargs, sandi, base62, base91, utf8-string, bytestring, byteslice, either-unwrap, text-show, hxt,haskoin-core, text, bytes, cborg, text-latin1,HTTP
|
||||
-- hs-source-dirs:
|
||||
default-language: Haskell2010
|
||||
|
|
Loading…
Reference in New Issue