ascii85

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec struct{}

Codec is a Codec[[]byte] backed by encoding/ascii85. It is safe for concurrent use.

func NewCodec

func NewCodec() *Codec

NewCodec returns an ASCII85 serializer.

Example
package main

import (
	"fmt"

	"github.com/foomo/goencode/ascii85"
)

func main() {
	c := ascii85.NewCodec()

	encoded, err := c.Encode([]byte("hello"))
	if err != nil {
		fmt.Printf("Encode failed: %v\n", err)
		return
	}

	fmt.Printf("Encoded: %s\n", string(encoded))

	var decoded []byte
	if err := c.Decode(encoded, &decoded); err != nil {
		fmt.Printf("Decode failed: %v\n", err)
		return
	}

	fmt.Printf("Decoded: %s\n", string(decoded))
}
Output:
Encoded: BOu!rDZ
Decoded: hello

func (Codec) Decode

func (Codec) Decode(b []byte, v *[]byte) error

func (Codec) Encode

func (Codec) Encode(v []byte) ([]byte, error)

type StreamCodec

type StreamCodec struct{}

StreamCodec is a StreamCodec[[]byte] backed by encoding/ascii85. It is safe for concurrent use.

func NewStreamCodec

func NewStreamCodec() StreamCodec

NewStreamCodec returns an ASCII85 stream serializer.

Example
package main

import (
	"bytes"
	"fmt"

	"github.com/foomo/goencode/ascii85"
)

func main() {
	c := ascii85.NewStreamCodec()

	var buf bytes.Buffer
	if err := c.Encode(&buf, []byte("hello")); err != nil {
		fmt.Printf("Encode failed: %v\n", err)
		return
	}

	fmt.Printf("Encoded: %s\n", buf.String())

	var decoded []byte
	if err := c.Decode(bytes.NewReader(buf.Bytes()), &decoded); err != nil {
		fmt.Printf("Decode failed: %v\n", err)
		return
	}

	fmt.Printf("Decoded: %s\n", string(decoded))
}
Output:
Encoded: BOu!rDZ
Decoded: hello

func (StreamCodec) Decode

func (StreamCodec) Decode(r io.Reader, v *[]byte) error

func (StreamCodec) Encode

func (StreamCodec) Encode(w io.Writer, v []byte) error

Jump to

Keyboard shortcuts

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