Git Product home page Git Product logo

dataenc's Introduction

Note: This package is obsolete and should no longer be used. This repository stays up purely for archival purposes.


Data Encodings (dataenc): A collection of data encoding algorithms.

Data encodings library

The data encodings library strives to provide implementations in Haskell of every major data encoding, and a few minor ones as well. Currently the following encodings are implemented:

  • Base16 (Codec.Binary.Base16)
  • Base32 (Codec.Binary.Base32)
  • Base32Hex (Codec.Binary.Base32Hex)
  • Base64 (Codec.Binary.Base64)
  • Base64Url (Codec.Binary.Base64Url)
  • Base85 (Codec.Binary.Base85)
  • Python string escaping (Codec.Binary.PythonString)
  • Quoted-Printable (Codec.Binary.QuotedPrintable)
  • URL encoding (Codec.Binary.Url)
  • Uuencode (Codec.Binary.Uu)
  • Xxencode (Codec.Binary.Xx)
  • yEncode (Codec.Binary.Yenc)

In some cases the encodings also specify headers and footers for the encoded data. Implementation of that is left for the user of the library.

The API

Main API

The module Codec.Binary.DataEncoding provides a type that collects the functions for an individual encoding:

data DataCodec = DataCodec {
    encode :: [Word8] -> String,
    decode :: String -> Maybe [Word8],
    decode' :: String -> [Maybe Word8],
    chop :: Int -> String -> [String],
    unchop :: [String] -> String
}

It also exposes instances of this type for each encoding:

base16 :: DataCodec
base32 :: DataCodec
base32Hex :: DataCodec
base64 :: DataCodec
base64Url :: DataCodec
uu :: DataCodec

NB There is no instance for yEncoding since the functions in that module have slightly different type signatures.

Secondary API

Each individual encoding module is also exposed and offers four functions:

encode :: [Word8] -> String
decode :: String -> Maybe [Word8]
decode' :: String -> [Maybe Word8]
chop :: Int -> String -> [String]
unchop :: [String] -> String

Description of the encodings

Base16

Implemented as it's defined in RFC 4648.

Each four bit nibble of an octet is encoded as a character in the set 0-9,A-F.

Base32

Implemented as it's defined in RFC 4648.

Five octets are expanded into eight so that only the five least significant bits are used. Each is then encoded into a 32-character encoding alphabet.

Base32Hex

Implemented as it's defined in RFC 4648.

Just like Base32 but with a different encoding alphabet. Unlike Base64 and Base32, data encoded with Base32Hex maintains its sort order when the encoded data is compared bit wise.

Base64

Implemented as it's defined in RFC 4648.

Three octets are expanded into four so that only the six least significant bits are used. Each is then encoded into a 64-character encoding alphabet.

Base64Url

Implemented as it's defined in RFC 4648.

Just like Base64 but with a different encoding alphabet. The encoding alphabet is made URL and filename safe by substituting + and / for - and _ respectively.

Base85

Implementation as described in the Wikipedia article.

Python string escaping

Implementation of Python's string escaping.

Quoted-Printable

Implemented as defined in RFC 2045.

URL encoding

Implemented as defined in RFC 3986.

Uuencode

Unfortunately uuencode is badly specified and there are in fact several differing implementations of it. This implementation attempts to encode data in the same way as the uuencode utility found in GNU's sharutils. The workings of chop and unchop also follow how sharutils split and unsplit encoded lines.

Xxencode

Implemented as described in the Wikipedia article.

yEncoding

Implemented as it's defined in the 1.3 draft.

Downloading

The current release is available from [http://hackage.haskell.org/package/dataenc].

Example of use

The package omnicodec contains two command line tools for encoding and decoding data.

Contributing

The source is hosted on github and can be downloaded using git:

git clone https://github.com/scrive/dataenc.git

dataenc's People

Contributors

magthe avatar gracjan avatar jonathanjouty avatar 23skidoo avatar vincenthz avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.