Base 16/32/64 codecs for TranscodingStreams.jl
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
benchmark
src
test
.codecov.yml
.gitignore
.travis.yml
LICENSE.md
README.md
REQUIRE
appveyor.yml

README.md

CodecBase.jl

TravisCI Status codecov.io

Installation

Pkg.add("CodecBase")

Usage

using CodecBase

# UTF8-encoded text.
data = """
祇園精舎の鐘の声、諸行無常の響きあり。
沙羅双樹の花の色、盛者必衰のことわりをあらはす。
奢れる人も久しからず、唯春の夜の夢のごとし。
"""

# Base64-encoded data of the above.
base64 = """
56WH5ZyS57K+6IiO44Gu6ZCY44Gu5aOw44CB6Ku46KGM54Sh5b
i444Gu6Z+/44GN44GC44KK44CCCuaymee+heWPjOaoueOBruiK
seOBruiJsuOAgeebm+iAheW/heihsOOBruOBk+OBqOOCj+OCiu
OCkuOBguOCieOBr+OBmeOAggrlpaLjgozjgovkurrjgoLkuYXj
gZfjgYvjgonjgZrjgIHllK/mmKXjga7lpJzjga7lpKLjga7jgZ
TjgajjgZfjgIIK
"""

# Streaming API.
encoded = readstring(Base64EncoderStream(IOBuffer(data)))
@assert encoded == replace(base64, "\n", "")
decoded = read(Base64DecoderStream(IOBuffer(base64)))
@assert decoded == Vector{UInt8}(data)

# Byte array API.
encoded = transcode(Base64Encoder(), data)
@assert String(encoded) == replace(base64, "\n", "")
decoded = transcode(Base64Decoder(), base64)
@assert decoded == Vector{UInt8}(data)

This package exports following codecs and streams:

Codec Stream
Base16Encoder Base16EncoderStream
Base16Decoder Base16DecoderStream
Base32Encoder Base32EncoderStream
Base32Decoder Base32DecoderStream
Base64Encoder Base64EncoderStream
Base64Decoder Base64DecoderStream

See docstrings and TranscodingStreams.jl for details.