base64x

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 2

README

base64x

High performance drop-in replacement of the encoding/base64 library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoding

type Encoding int

An Encoding is a radix 64 encoding/decoding scheme, defined by a 64-character alphabet. The most common encoding is the "base64" encoding defined in RFC 4648 and used in MIME (RFC 2045) and PEM (RFC 1421). RFC 4648 also defines an alternate encoding, which is the standard encoding with - and _ substituted for + and /.

const JSONStdEncoding Encoding = _MODE_JSON

JSONStdEncoding is the StdEncoding and encoded as JSON string as RFC 8259.

const RawStdEncoding Encoding = _MODE_RAW

RawStdEncoding is the standard raw, unpadded base64 encoding, as defined in RFC 4648 section 3.2.

This is the same as StdEncoding but omits padding characters.

const RawURLEncoding Encoding = _MODE_RAW | _MODE_URL

RawURLEncoding is the unpadded alternate base64 encoding defined in RFC 4648. It is typically used in URLs and file names.

This is the same as URLEncoding but omits padding characters.

const StdEncoding Encoding = 0

StdEncoding is the standard base64 encoding, as defined in RFC 4648.

const URLEncoding Encoding = _MODE_URL

URLEncoding is the alternate base64 encoding defined in RFC 4648. It is typically used in URLs and file names.

func (Encoding) Decode

func (self Encoding) Decode(out []byte, src []byte) (int, error)

Decode decodes src using the encoding enc. It writes at most DecodedLen(len(src)) bytes to out and returns the number of bytes written. If src contains invalid base64 data, it will return the number of bytes successfully written and base64.CorruptInputError.

New line characters (\r and \n) are ignored.

If out is not large enough to contain the encoded result, it will panic.

func (Encoding) DecodeString

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

DecodeString returns the bytes represented by the base64 string s.

func (Encoding) DecodeUnsafe

func (self Encoding) DecodeUnsafe(out *[]byte, src []byte) (int, error)

DecodeUnsafe behaves like Decode, except it does NOT check if out is large enough to contain the decoded result.

It will also update the length of out.

func (Encoding) DecodedLen

func (self Encoding) DecodedLen(n int) int

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

func (Encoding) Encode

func (self Encoding) Encode(out []byte, src []byte)

Encode encodes src using the specified encoding, writing EncodedLen(len(src)) bytes to out.

The encoding pads the output to a multiple of 4 bytes, so Encode is not appropriate for use on individual blocks of a large data stream.

If out is not large enough to contain the encoded result, it will panic.

func (Encoding) EncodeToString

func (self Encoding) EncodeToString(src []byte) string

EncodeToString returns the base64 encoding of src.

func (Encoding) EncodeUnsafe

func (self Encoding) EncodeUnsafe(out *[]byte, src []byte)

EncodeUnsafe behaves like Encode, except it does NOT check if out is large enough to contain the encoded result.

It will also update the length of out.

func (Encoding) EncodedLen

func (self Encoding) EncodedLen(n int) int

EncodedLen returns the length in bytes of the base64 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