buffer

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package buffer provides a very thin wrapper around []byte buffer called `Buffer`, to provide functionalities that are often used within the jwx related packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer []byte

Buffer wraps `[]byte` and provides functions that are often used in the jwx related packages. One notable difference is that while encoding/json marshalls `[]byte` using base64.StdEncoding, this module uses base64.RawURLEncoding as mandated by the spec

func FromBase64

func FromBase64(v []byte) (Buffer, error)

FromBase64 constructs a new Buffer from a base64 encoded data

func FromNData

func FromNData(v []byte) (Buffer, error)

FromNData constructs a new Buffer from a "n:data" format (I made that name up)

func FromUint

func FromUint(v uint64) Buffer

FromUint creates a `Buffer` from an unsigned int

func (*Buffer) Base64Decode

func (b *Buffer) Base64Decode(v []byte) error

Base64Decode decodes the contents of the Buffer using base64.RawURLEncoding

func (Buffer) Base64Encode

func (b Buffer) Base64Encode() ([]byte, error)

Base64Encode encodes the contents of the Buffer using base64.RawURLEncoding

func (Buffer) Bytes

func (b Buffer) Bytes() []byte

Bytes returns the raw bytes that comprises the Buffer

func (Buffer) Len

func (b Buffer) Len() int

Len returns the number of bytes that the Buffer holds

func (Buffer) MarshalJSON

func (b Buffer) MarshalJSON() ([]byte, error)

MarshalJSON marshals the buffer into JSON format after encoding the buffer with base64.RawURLEncoding

func (Buffer) NData

func (b Buffer) NData() []byte

NData returns Datalen || Data, where Datalen is a 32 bit counter for the length of the following data, and Data is the octets that comprise the buffer data

func (*Buffer) UnmarshalJSON

func (b *Buffer) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals from a JSON string into a Buffer, after decoding it with base64.RawURLEncoding

Jump to

Keyboard shortcuts

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