base91

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2017 License: BSD-3-Clause Imports: 1 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

base91-go

Travis Go Report Card license GoDoc

basE91 codec implemented in Golang.

Migrated from the C and PHP version of Joachim Henke's basE91.

Nodejs version

Install

$ go get -u ekyu.moe/base91

Example

package main

import (
    "fmt"

    "ekyu.moe/base91"
)

func main() {
    fmt.Println(base91.EncodeToString([]byte("Hello, 世界"))) //=> >OwJh>}AFU~PUh%Y
    fmt.Println(string(base91.DecodeString(">OwJh>}AFU~PUh%Y"))) //=> Hello, 世界
}

Check godoc for further documents.

A CLI utility is also available with go get ekyu.moe/base91/cmd/base91.

Benchmark

Note: 1 op = 1 MB input

$ go test -bench . -benchmem ekyu.moe/base91
goos: windows
goarch: amd64
pkg: ekyu.moe/base91
BenchmarkDecode-4            300           4841614 ns/op         7157763 B/op         36 allocs/op
BenchmarkDecoder-4            50          35287190 ns/op         6324756 B/op        920 allocs/op
BenchmarkEncode-4            300           5910366 ns/op         8673280 B/op         37 allocs/op
BenchmarkEncoder-4           200           5865032 ns/op         2324512 B/op         24 allocs/op
PASS
ok      ekyu.moe/base91 10.910s

(Approximately, 170.50 MB/s of encode speed and 6.81 MB/s of decode speed)

License

BSD-3-clause

Documentation

Overview

Package base91 implements a base91 encoder and decoder.

base91 is defined in Joachim Henke's basE91: http://base91.sourceforge.net/

Index

Constants

This section is empty.

Variables

View Source
var (
	EmailLineWrap = 76
)

Functions

func Decode

func Decode(dst, src []byte) int

Decode decodes src into dst. It returns the number of bytes written to dst. Whereas base91 uses up to nearly all printable characters, Decode skips invalid characters silently.

func DecodeString

func DecodeString(s string) []byte

DecodeString returns the bytes represented by the base91 string s, probably what you want.

func Encode

func Encode(dst, src []byte) int

Encode encodes src into dst. It returns the number of bytes written to dst.

func EncodeToString

func EncodeToString(src []byte) string

EncodeToString returns the encoded base91 string of src, probably what you want.

func NewDecoder

func NewDecoder(r io.Reader) io.Reader

NewDecoder constructs a new base91 stream decoder. Data read from the returned reader is base91 decoded from r.

func NewEncoder

func NewEncoder(w io.Writer) io.WriteCloser

NewEncoder returns a new base91 stream encoder. Data written to the returned writer will be encoded using base91 and then written to w. When finished writing, the caller must Close the returned encoder to flush any partially written blocks.

func NewLineWrapper added in v0.2.0

func NewLineWrapper(w io.Writer, cols int) io.WriteCloser

NewLineWrapper returns an base91 encoeder that encode data and insert CRLF every cols characters. This is useful for emails.

Types

This section is empty.

Directories

Path Synopsis
cmd
base91 command
base91: a cli utility for base91 encode/decode.
base91: a cli utility for base91 encode/decode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL