base91

package module
v0.0.0-...-7f4cdc2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: BSD-3-Clause Imports: 1 Imported by: 12

Documentation

Overview

base91 is a Go adaptation for the en-/decoding library to encoding binary data as ASCII. It is based on the C version from basE91 (http://base91.sourceforge.net/).

Index

Examples

Constants

This section is empty.

Variables

View Source
var LineBreakAfter uint = 76

Functions

func Decode

func Decode(data []byte) []byte

Decode takes base91 data and returns it in decoded form. Please use the faster NewDecoder(src io.Reader) io.Reader implementation if possible.

Example
package main

import (
	"fmt"

	"catinello.eu/base91"
)

func main() {
	in := []byte("fGn/1+~j/nFa!YAS77Z.wnXBD")
	out := base91.Decode(in)

	fmt.Println(string(out))
}
Output:

ABC_def→1234567890

func Encode

func Encode(data []byte) []byte

Encode takes data and returns it in base91 encoded form. Please use the faster NewEncoder(dst io.Writer) io.WriteCloser implementation if possible.

Example
package main

import (
	"fmt"

	"catinello.eu/base91"
)

func main() {
	in := []byte("ABC_def→1234567890")
	out := base91.Encode(in)

	fmt.Println(string(out))
}
Output:

fGn/1+~j/nFa!YAS77Z.wnXBD

func NewDecoder

func NewDecoder(src io.Reader) io.Reader

NewDecoder takes an io.Reader as source to read encoded data from.

Example
package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"

	"catinello.eu/base91"
)

func main() {
	sample := []byte("fGn/1+~j/nFa!YAS77Z.wnXBD")
	r := bytes.NewReader(sample)

	d := base91.NewDecoder(r)

	var w []byte

	_, err := d.Read(w)
	if err != nil {
		log.Fatalf("Error decoding `%s`", sample)
	}

	buf, err := ioutil.ReadAll(d)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(string(buf))
}
Output:

ABC_def→1234567890

func NewEncoder

func NewEncoder(dst io.Writer) io.WriteCloser

NewEncoder takes an io.Writer as destination to write encoded data to.

Example
package main

import (
	"bytes"
	"fmt"
	"log"

	"catinello.eu/base91"
)

func main() {
	var sample []byte = []byte("ABC_def→1234567890")
	w := &bytes.Buffer{}
	e := base91.NewEncoder(w)
	_, err := e.Write(sample)
	if err != nil {
		log.Fatalf("Error encoding `%s`", sample)
	}

	err = e.Close()
	if err != nil {
		log.Fatalf("Error encoding `%s`", sample)
	}

	fmt.Println(w.String())
}
Output:

fGn/1+~j/nFa!YAS77Z.wnXBD

func NewEncoderWrapped

func NewEncoderWrapped(dst io.Writer) io.WriteCloser

NewEncoderWrapped takes an io.Writer as destination to write encoded data to and wraps the line after LineBreakAfter (defaults to 76).

Types

This section is empty.

Directories

Path Synopsis
cmd
base91 module

Jump to

Keyboard shortcuts

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