base100

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: MIT Imports: 2 Imported by: 0

README ยถ

Base๐Ÿ’ฏ

Go Reference

A Go implementation of base100 with a permissive software license.

Base๐Ÿ’ฏ can represent any byte with a unique emoji symbol, therefore it can represent binary data with zero printable overhead.

Usage

Library

The API is nearly identical to other modules from the Go encoding/* standard library. See the Go Docs for more information.

Command line tool

A CLI tool is also provided for convenience, and ease of cross-compilation for multiple operating systems.

base๐Ÿ’ฏ (Go)
Encodes things into emoji

USAGE:
    base100 [FLAGS]

FLAGS:
    -d, --decode     Decodes input
    -i, --input      Input file (default use STDIN)
    -o, --output     Output file (default use STDOUT)
    -h, --help       Prints help information

base100 will read from stdin unless a file is specified, will write UTF-8 to stdout, and has a similar API to GNU's base64. Data is encoded by default, unless --decode is specified

Performance

The implementation is fairly performant, and appears to perform roughly equivalent to the scalar Rust version on my machine. A future optimization utilizing SIMD/AVX could be possible with Go assembly code, however the throughput already far exceeds any known use case I can see for this, so I'll leave that out unless I get incredibly bored some day.

Library single-cpu benchmarks from my laptop (the throughput values are the relevant ones):

$ go test -bench=. -cpu=1
goos: darwin
goarch: arm64
pkg: github.com/mroth/base100-go
cpu: Apple M2 Pro
BenchmarkEncode                 24076875                49.24 ns/op      913.81 MB/s
BenchmarkEncodeToString         12909928                90.94 ns/op      494.83 MB/s
BenchmarkDecode                 31709400                37.85 ns/op     1189.02 MB/s
BenchmarkDecodeString           25889036                45.45 ns/op      990.11 MB/s
BenchmarkEncoder                   18339             65083 ns/op        1006.96 MB/s
BenchmarkDecoder                   21528             56465 ns/op        1160.65 MB/s

Documentation ยถ

Overview ยถ

Package base100 provides a Go implementation of Base๐Ÿ’ฏ.

For the original Rust version see https://github.com/AdamNiederer/base100.

Index ยถ

Examples ยถ

Constants ยถ

This section is empty.

Variables ยถ

This section is empty.

Functions ยถ

func Decode ยถ

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

Decode decodes src using base100. It writes at most DecodedLen(len(src)) bytes to dst and returns the number of bytes written.

New line characters (\r and \n) should be stripped beforehand.

Example ยถ
src := []byte("๐Ÿ‘ซ๐Ÿ‘Ÿ๐Ÿ‘œ๐Ÿ—๐Ÿ‘จ๐Ÿ‘ฌ๐Ÿ‘ ๐Ÿ‘š๐Ÿ‘ข๐Ÿ—๐Ÿ‘™๐Ÿ‘ฉ๐Ÿ‘ฆ๐Ÿ‘ฎ๐Ÿ‘ฅ๐Ÿ—๐Ÿ‘๐Ÿ‘ฆ๐Ÿ‘ฏ๐Ÿ—๐Ÿ‘ก๐Ÿ‘ฌ๐Ÿ‘ค๐Ÿ‘ง๐Ÿ‘œ๐Ÿ‘›๐Ÿ—๐Ÿ‘ฆ๐Ÿ‘ญ๐Ÿ‘œ๐Ÿ‘ฉ๐Ÿ—๐Ÿ‘ซ๐Ÿ‘Ÿ๐Ÿ‘œ๐Ÿ—๐Ÿ‘ฃ๐Ÿ‘˜๐Ÿ‘ฑ๐Ÿ‘ฐ๐Ÿ—๐Ÿ‘›๐Ÿ‘ฆ๐Ÿ‘ž๐Ÿ")
dst := make([]byte, base100.DecodedLen(len(src)))
_, err := base100.Decode(dst, src)
if err != nil {
	log.Fatal(err)
}
fmt.Printf("%s", dst)
Output:
the quick brown fox jumped over the lazy dog

func DecodeString ยถ

func DecodeString(s string) ([]byte, error)

DecodeString returns the bytes represented by the base100 string s.

Example ยถ
src := "๐Ÿ‘ซ๐Ÿ‘Ÿ๐Ÿ‘œ๐Ÿ—๐Ÿ‘จ๐Ÿ‘ฌ๐Ÿ‘ ๐Ÿ‘š๐Ÿ‘ข๐Ÿ—๐Ÿ‘™๐Ÿ‘ฉ๐Ÿ‘ฆ๐Ÿ‘ฎ๐Ÿ‘ฅ๐Ÿ—๐Ÿ‘๐Ÿ‘ฆ๐Ÿ‘ฏ๐Ÿ—๐Ÿ‘ก๐Ÿ‘ฌ๐Ÿ‘ค๐Ÿ‘ง๐Ÿ‘œ๐Ÿ‘›๐Ÿ—๐Ÿ‘ฆ๐Ÿ‘ญ๐Ÿ‘œ๐Ÿ‘ฉ๐Ÿ—๐Ÿ‘ซ๐Ÿ‘Ÿ๐Ÿ‘œ๐Ÿ—๐Ÿ‘ฃ๐Ÿ‘˜๐Ÿ‘ฑ๐Ÿ‘ฐ๐Ÿ—๐Ÿ‘›๐Ÿ‘ฆ๐Ÿ‘ž๐Ÿ"
result, _ := base100.DecodeString(src)
fmt.Printf("%s", result)
Output:
the quick brown fox jumped over the lazy dog

func DecodedLen ยถ

func DecodedLen(n int) int

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

func Encode ยถ

func Encode(dst, src []byte)

Encode encodes src to its base100 encoding, writing EncodedLen(len(src)) bytes to dst.

Example ยถ
src := []byte("the quick brown fox jumped over the lazy dog\n")
dst := make([]byte, base100.EncodedLen(len(src)))
base100.Encode(dst, src)
fmt.Printf("%s", dst)
Output:
๐Ÿ‘ซ๐Ÿ‘Ÿ๐Ÿ‘œ๐Ÿ—๐Ÿ‘จ๐Ÿ‘ฌ๐Ÿ‘ ๐Ÿ‘š๐Ÿ‘ข๐Ÿ—๐Ÿ‘™๐Ÿ‘ฉ๐Ÿ‘ฆ๐Ÿ‘ฎ๐Ÿ‘ฅ๐Ÿ—๐Ÿ‘๐Ÿ‘ฆ๐Ÿ‘ฏ๐Ÿ—๐Ÿ‘ก๐Ÿ‘ฌ๐Ÿ‘ค๐Ÿ‘ง๐Ÿ‘œ๐Ÿ‘›๐Ÿ—๐Ÿ‘ฆ๐Ÿ‘ญ๐Ÿ‘œ๐Ÿ‘ฉ๐Ÿ—๐Ÿ‘ซ๐Ÿ‘Ÿ๐Ÿ‘œ๐Ÿ—๐Ÿ‘ฃ๐Ÿ‘˜๐Ÿ‘ฑ๐Ÿ‘ฐ๐Ÿ—๐Ÿ‘›๐Ÿ‘ฆ๐Ÿ‘ž๐Ÿ

func EncodeToString ยถ

func EncodeToString(src []byte) string

EncodeToString returns the base100 encoding of src.

Example ยถ
src := []byte("the quick brown fox jumped over the lazy dog\n")
fmt.Println(base100.EncodeToString(src))
Output:
๐Ÿ‘ซ๐Ÿ‘Ÿ๐Ÿ‘œ๐Ÿ—๐Ÿ‘จ๐Ÿ‘ฌ๐Ÿ‘ ๐Ÿ‘š๐Ÿ‘ข๐Ÿ—๐Ÿ‘™๐Ÿ‘ฉ๐Ÿ‘ฆ๐Ÿ‘ฎ๐Ÿ‘ฅ๐Ÿ—๐Ÿ‘๐Ÿ‘ฆ๐Ÿ‘ฏ๐Ÿ—๐Ÿ‘ก๐Ÿ‘ฌ๐Ÿ‘ค๐Ÿ‘ง๐Ÿ‘œ๐Ÿ‘›๐Ÿ—๐Ÿ‘ฆ๐Ÿ‘ญ๐Ÿ‘œ๐Ÿ‘ฉ๐Ÿ—๐Ÿ‘ซ๐Ÿ‘Ÿ๐Ÿ‘œ๐Ÿ—๐Ÿ‘ฃ๐Ÿ‘˜๐Ÿ‘ฑ๐Ÿ‘ฐ๐Ÿ—๐Ÿ‘›๐Ÿ‘ฆ๐Ÿ‘ž๐Ÿ

func EncodedLen ยถ

func EncodedLen(n int) int

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

func NewDecoder ยถ

func NewDecoder(r io.Reader) io.Reader

NewDecoder constructs a new base100 stream decoder.

func NewEncoder ยถ

func NewEncoder(w io.Writer) io.Writer

NewEncoder returns a new base100 stream encoder. Data written to the returned writer will be encoded using base100 and then written to w.

Types ยถ

This section is empty.

Directories ยถ

Path Synopsis
cmd
base100 command

Jump to

Keyboard shortcuts

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