b64buff

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package b64buff implements a bit buffer that can be represented as URL string.

The bit buffer allows to read and write any number of bits. The encoding is similar to Base64 but different. It has no padding. Currently it cannot be changed.

Index

Constants

This section is empty.

Variables

View Source
var (
	WrongNbBits   = errors.New("Impossible number of bits")
	NotEnoughData = errors.New("No enough data to read")
	NotAligned    = errors.New("Buffer not aligned")
	EncodingError = errors.New("Error in encoding")
)

Functions

This section is empty.

Types

type Buffer

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

Buffer is a bit buffer.

func (*Buffer) Len

func (self *Buffer) Len() uint32

Len returns the number of bits in the buffer.

func (*Buffer) ReadAllB64

func (self *Buffer) ReadAllB64() (ret string, err error)

ReadAllB64 reads the whole buffer to the string.

The call fails if the read is not aligned. The read is aligned if the sum of read bits from the buffer can be divided by 6.

func (*Buffer) ReadUInt32

func (self *Buffer) ReadUInt32(nbBits uint8) (ret uint32, err error)

ReadUInt32 reads nbBits of the buffer into the lower bits of ret.

func (*Buffer) WriteB64

func (self *Buffer) WriteB64(str string) (err error)

WriteB64 writes the whole string into the buffer.

The string must have been correctly encoded by a call to ReadAllB64.

The call fails if the write is not aligned. The write is aligned if the sum of written bits into the buffer can be divided by 6.

func (*Buffer) WriteUInt32

func (self *Buffer) WriteUInt32(data uint32, nbBits uint8) error

WriteUInt32 writes the lower nbBits of data to the buffer.

Jump to

Keyboard shortcuts

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