Base64
Faster base64 encoding for Go
Install / Use
/learn @cristalhq/Base64README
base64
Faster base64 encoding for Go, based on Turbo-Base64.
Features
- Drop-in replacement of
encoding/base64.- except for error messages and ignoring
\rand\nin decoder.
- except for error messages and ignoring
- 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
Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
339.3kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
