base64

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

base64 supports Base64 encoding and decoding.

Index

Constants

View Source
const (
	// RxCheckMore is from https://stackoverflow.com/a/8571649/1908967
	RxCheckMore      = `^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$`
	RxCheckSimple    = `^[0-9A-Za-z/\+]*=*$`
	RxCheckNoPadding = `^[0-9A-Za-z/\+]*$`
)

Variables

This section is empty.

Functions

func Decode added in v1.0.2

func Decode(input []byte) ([]byte, error)

Decode decodes a byte array to provide an interface like `base64/DecodeString`.

func DecodeGunzip added in v1.0.1

func DecodeGunzip(encoded string) ([]byte, error)

DecodeGunzip base64 decodes a string with optional gzip uncompression.

func DecodeGunzipJSON added in v1.0.1

func DecodeGunzipJSON(encoded string, output interface{}) error

DecodeGunzipJSON base64 decodes a string with optoinal gunzip uncompression and then unmarshals the data to a struct.

func EncodeGzip added in v1.0.1

func EncodeGzip(data []byte, compressLevel int) string

Encode with optional gzip compression. 0 = no compression. 9 = best compression.

func EncodeGzipJSON added in v1.0.1

func EncodeGzipJSON(data interface{}, compressLevel int) (string, error)

EncodeGzipJSON encodes a struct that is JSON encoded.

func IsValid added in v1.0.2

func IsValid(input []byte) bool

func IsValidString added in v1.0.2

func IsValidString(input string) bool

func Pad added in v1.0.1

func Pad(encoded string) string

func ReadAll added in v1.0.2

func ReadAll(r io.Reader) ([]byte, error)

ReadAll provides an interface like `ioutil.ReadAll` with optional base64 decoding. It is useful for decoding `*http.Response.Body`.

func StripPadding

func StripPadding(str string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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