Faster base64 encoding for Go

base64

build-img pkg-img reportcard-img coverage-img

Faster base64 encoding for Go, based on Turbo-Base64.

Features

  • Drop-in replacement of encoding/base64.
    • except for error messages and ignoring \r and \n in decoder.
  • up to 3 times faster than encoding/base64.
  • Dependency-free.

Install

Go version 1.16+

go get github.com/cristalhq/base64

How to use

Replace import statement from encoding/base64 to github.com/cristalhq/base64

-import "encoding/base64"
+import "github.com/cristalhq/base64"

Benchmarks

go1.17 linux/amd64, Intel i7-7700

std/Encode           685.3 ns/op      0 B/op   0 allocs/op
std/EncodeToString   951.8 ns/op   2048 B/op   2 allocs/op
std/Decode           803.9 ns/op      0 B/op   0 allocs/op
std/DecodeString     1061 ns/op    1792 B/op   2 allocs/op

own/Encode           217.8 ns/op      0 B/op   0 allocs/op
own/EncodeToString   353.2 ns/op   1024 B/op   1 allocs/op
own/Decode           426.0 ns/op      0 B/op   0 allocs/op
own/DecodeString     598.7 ns/op    768 B/op   1 allocs/op

go1.17 darwin/arm64, Apple M1

std/Encode           413.0 ns/op       0 B/op  0 allocs/op
std/EncodeToString   608.3 ns/op    2048 B/op  2 allocs/op
std/Decode           372.5 ns/op       0 B/op  0 allocs/op
std/DecodeString     570.2 ns/op    1792 B/op  2 allocs/op

own/Encode           146.7 ns/op       0 B/op  0 allocs/op
own/EncodeToString   246.4 ns/op    1024 B/op  1 allocs/op
own/Decode           222.8 ns/op       0 B/op  0 allocs/op
own/DecodeString     303.1 ns/op     768 B/op  1 allocs/op

Fuzzing

Documentation

See these docs.

License

MIT License.

Owner
cristaltech
Better open source
cristaltech
Similar Resources

a little app to gzip+base64 encode and decode

GO=GZIP64 A little golang console utility that reads a file and either: 1) Encodes it - gzip compress followed by base64 encode writes

Oct 16, 2021

Simple base64 coder/decoder written in Golang

base64-coder simple base64 coder/decoder written in Golang ๐Ÿ–ฑ๏ธ Releases usage example Encode: ./b64 encode from.txt to.dat Decode: ./b64 encode to.dat

Jan 4, 2022

? ID3 decoding and encoding library for Go

id3v2 Supported ID3 versions: 2.3, 2.4 Installation go get -u github.com/bogem/id3v2 Usage example package main import ( "fmt" "log" "github.com

Dec 31, 2022

Package go-otp implements one-time-password generators used in 2-factor authentication systems like RSA-tokens. Currently this supports both HOTP (RFC-4226), TOTP (RFC-6238) and Base32 encoding (RFC-3548) for Google Authenticator compatibility

OTP Package go-otp implements one-time-password generators used in 2-factor authentication systems like RSA-tokens and Google Authenticator. Currently

Oct 8, 2022

A Go implementation of the Elias-Fano encoding

go-ef A Go implementation of the Elias-Fano encoding Example package main import ( "fmt" "github.com/amallia/go-ef" "os" ) func main() {

Nov 23, 2022

Base58 encoding for Go

Base58 encoding for Go Base58 is a less known encoding, but it is popular when embedding resource identifiers into URLs. The encoded data contains onl

Dec 20, 2021

msgpack.org[Go] MessagePack encoding for Golang

MessagePack encoding for Golang โค๏ธ Uptrace.dev - distributed traces, logs, and errors in one place Join Discord to ask questions. Documentation Refere

Dec 28, 2022

Go module for encoding structs into URL query parameters

qs Package sonh/qs encodes structs into url.Values. Installation go get github.com/sonh/qs Usage import ( "github.com/sonh/qs" ) Package qs export

Jan 7, 2023

Encoding and decoding GeoJSON - Go

go.geojson Go.geojson is a package for encoding and decoding GeoJSON into Go structs. Supports both the json.Marshaler and json.Unmarshaler interfaces

Jan 2, 2023

Package polyline implements a Google Maps Encoding Polyline encoder and decoder.

go-polyline Package polyline implements a Google Maps Encoding Polyline encoder and decoder. Encoding example func ExampleEncodeCoords() { coords :=

Dec 1, 2022

Go package for decoding and encoding TARGA image format

tga tga is a Go package for decoding and encoding TARGA image format. It supports RLE and raw TARGA images with 8/15/16/24/32 bits per pixel, monochro

Sep 26, 2022

:eyeglasses: Go library for [d]encoding glTF 2.0 files

:eyeglasses: Go library for [d]encoding glTF 2.0 files

gltf A Go module for efficient and robust serialization/deserialization of glTF 2.0, a royalty-free specification for the efficient transmission and l

Jan 1, 2023

goworker is a Go-based background worker that runs 10 to 100,000* times faster than Ruby-based workers.

goworker goworker is a Resque-compatible, Go-based background worker. It allows you to push jobs into a queue using an expressive language like Ruby w

Jan 6, 2023

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http

fasthttp Fast HTTP implementation for Go. Currently fasthttp is successfully used by VertaMedia in a production serving up to 200K rps from more than

Jan 5, 2023

Asn.1 BER and DER encoding library for golang.

WARNING This repo has been archived! NO further developement will be made in the foreseen future. asn1 -- import "github.com/PromonLogicalis/asn1" Pac

Nov 14, 2022

A high-performance 100% compatible drop-in replacement of "encoding/json"

A high-performance 100% compatible drop-in replacement of

A high-performance 100% compatible drop-in replacement of "encoding/json" You can also use thrift like JSON using thrift-iterator Benchmark Source cod

Jan 7, 2023

Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths. Up to 20x faster than html/template

quicktemplate A fast, powerful, yet easy to use template engine for Go. Inspired by the Mako templates philosophy. Features Extremely fast. Templates

Dec 26, 2022
Asn.1 BER and DER encoding library for golang.

WARNING This repo has been archived! NO further developement will be made in the foreseen future. asn1 -- import "github.com/PromonLogicalis/asn1" Pac

Nov 14, 2022
A high-performance 100% compatible drop-in replacement of "encoding/json"
A high-performance 100% compatible drop-in replacement of

A high-performance 100% compatible drop-in replacement of "encoding/json" You can also use thrift like JSON using thrift-iterator Benchmark Source cod

Jan 7, 2023
Fast implementation of base58 encoding on golang.

Fast Implementation of Base58 encoding Fast implementation of base58 encoding in Go. Base algorithm is adapted from https://github.com/trezor/trezor-c

Dec 9, 2022
msgpack.org[Go] MessagePack encoding for Golang

MessagePack encoding for Golang โค๏ธ Uptrace.dev - All-in-one tool to optimize performance and monitor errors & logs Join Discord to ask questions. Docu

Dec 28, 2022
GED - Global-purpose Encoding / Decoding library

GED - Global-purpose Encoding / Decoding library This library lets you use common encoding/decoding schemes and allows you to define custom ones. Use

Nov 28, 2021
Some Golang types based on builtin. Implements interfaces Value / Scan and MarshalJSON / UnmarshalJSON for simple working with database NULL-values and Base64 encoding / decoding.

gotypes Some simple types based on builtin Golang types that implement interfaces for working with DB (Scan / Value) and JSON (Marshal / Unmarshal). N

Feb 12, 2022
The web framework for writing faster sites, faster

Gondola The web framework for writing faster sites, faster. Written in Go. View documentation at http://gondolaweb.com. Unless indicated otherwise at

Nov 20, 2022
A faster RWLock primitive in Go, 2-3 times faster than RWMutex. A Go implementation of concurrency control algorithm in paper

Go Left Right Concurrency A Go implementation of the left-right concurrency control algorithm in paper <Left-Right - A Concurrency Control Technique w

Jan 6, 2023
go-eexcel implements encoding and decoding of XLSX like encoding/json

go-eexcel go-eexcel implements encoding and decoding of XLSX like encoding/json Usage func ExampleMarshal() { type st struct { Name string `eexce

Dec 9, 2021
captcha of base64 and diversity

A flexible and various captcha package Base64captcha supports any unicode character and can easily be customized to support Math Chinese Korean Japane

Dec 26, 2022