base64

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 4 Imported by: 20

README

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.
  • ~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

std/Encode           674.7 ns/op      0 B/op   0 allocs/op
std/EncodeToString   943.3 ns/op   2014 B/op   2 allocs/op
std/Decode           747.8 ns/op      0 B/op   0 allocs/op
std/DecodeString      1012 ns/op   1792 B/op   2 allocs/op

own/Encode           215.3 ns/op      0 B/op   0 allocs/op
own/EncodeToString   354.6 ns/op   1024 B/op   1 allocs/op
own/Decode           306.6 ns/op      0 B/op   0 allocs/op
own/DecodeString     440.0 ns/op    768 B/op   1 allocs/op

Documentation

See these docs.

License

MIT License.

Documentation

Overview

based on https://github.com/powturbo/Turbo-Base64

Index

Constants

This section is empty.

Variables

View Source
var (
	StdEncoding    = NewEncoding(stdLutSe, true)
	RawStdEncoding = NewEncoding(stdLutSe, false)
	URLEncoding    = NewEncoding(urlLutSe, true)
	RawURLEncoding = NewEncoding(urlLutSe, false)
)

Functions

This section is empty.

Types

type Encoding

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

func NewEncoding

func NewEncoding(lutSe [64]byte, pad bool) *Encoding

func (*Encoding) Decode

func (e *Encoding) Decode(dst []byte, src []byte) (int, error)

func (*Encoding) DecodeString

func (e *Encoding) DecodeString(src string) ([]byte, error)

func (*Encoding) DecodeStringToString

func (e *Encoding) DecodeStringToString(src string) (string, error)

func (*Encoding) DecodeToBytes

func (e *Encoding) DecodeToBytes(src []byte) ([]byte, error)

func (*Encoding) DecodeToString

func (e *Encoding) DecodeToString(src []byte) (string, error)

func (*Encoding) DecodedLen

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

func (*Encoding) Encode

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

func (*Encoding) EncodeString

func (e *Encoding) EncodeString(src string) []byte

func (*Encoding) EncodeStringToString

func (e *Encoding) EncodeStringToString(src string) string

func (*Encoding) EncodeToBytes

func (e *Encoding) EncodeToBytes(src []byte) []byte

func (*Encoding) EncodeToString

func (e *Encoding) EncodeToString(src []byte) string

func (*Encoding) EncodedLen

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

Directories

Path Synopsis
fuzz module

Jump to

Keyboard shortcuts

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