base64

package
v0.30.14 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 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

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

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

func DecodeGunzip

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

DecodeGunzip base64 decodes a string with optional gzip uncompression.

func DecodeGunzipJSON

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

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

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

func EncodeGzipJSON

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

EncodeGzipJSON encodes a struct that is JSON encoded.

func IsValid

func IsValid(input []byte) bool

func IsValidString

func IsValidString(input string) bool

func Pad

func Pad(encoded string) string

func ReadAll

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