base24

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0, MIT Imports: 4 Imported by: 1

README

Base24 encoder/decoder for Go

This library is an encoder/decoder for the Base24 encoding for the go programming language.

Usage

Install

go get gitlab.com/phil9909/base24

Encode

import "gitlab.com/phil9909/base24"

func main() {
  data, err := base24.StdEncoding.EncodeToString(/* some []byte array */)
  if err != nil {
    // ...
  }
  // ... 
}

Decode

import "gitlab.com/phil9909/base24"

func main() {
  data, err := base24.StdEncoding.DecodeString("ZZZZZZZ")
  if err != nil {
    // ...
  }
  // ... 
}

License

Licensed under either of

at your option.

Acknowledgment

The content of this repos is heavily inspiered by:

Documentation

Overview

Package base24 implements base24 encoding as specified by https://www.kuon.ch/post/2020-02-27-base24/

Index

Constants

This section is empty.

Variables

View Source
var StdEncoding = NewEncoding(encodeStd)

StdEncoding is a base24 encoding with the alphabet defined in https://www.kuon.ch/post/2020-02-27-base24/

Functions

This section is empty.

Types

type Encoding

type Encoding struct {
	// contains filtered or unexported fields
}

Encoding Most of the time you want to use StdEncoding, but you can provide a custom alphabet using NewEncoding

func NewEncoding

func NewEncoding(encoder string) *Encoding

NewEncoding returns an Encoding defined by the given alphabet, The alphabet must be 24 distinct characters

func (*Encoding) Decode

func (enc *Encoding) Decode(dst, src []byte) (n int, err error)

Decode decodes src into dst. DecodedLen(len(src)) bytes will be written to dst. len(src) must be a multiple of 7. Might return an error when invalid data is given See https://www.kuon.ch/post/2020-02-27-base24/ for details

func (*Encoding) DecodeString

func (enc *Encoding) DecodeString(s string) ([]byte, error)

DecodeString returns the bytes represented by the base24 string s.

func (*Encoding) DecodedLen

func (enc *Encoding) DecodedLen(n int) int

DecodedLen returns the maximum length in bytes of the decoded data corresponding to n bytes of base24-encoded data.

func (*Encoding) Encode

func (enc *Encoding) Encode(dst, src []byte) error

Encode encodes src into dst. EncodedLen(len(src)) bytes will be written to dst. len(src) must be a multiple of 4. See https://www.kuon.ch/post/2020-02-27-base24/ for details

func (*Encoding) EncodeToString

func (enc *Encoding) EncodeToString(src []byte) (string, error)

EncodeToString returns the base24 encoding of src as string

func (*Encoding) EncodedLen

func (enc *Encoding) EncodedLen(n int) int

EncodedLen returns the length in bytes of the base24 encoding of an input buffer of length n.

Jump to

Keyboard shortcuts

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