encoder

package
v1.5.2 Latest Latest
Warning

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

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

Documentation

Overview

Package encoder provides implementations for data encoding and continuation token encoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base64Encoder

type Base64Encoder struct{}

Base64Encoder adheres to the Encoder interface, utilizing the encoding/base64 encoding strategy for base64 encoding.

func NewBase64Encoder

func NewBase64Encoder() *Base64Encoder

NewBase64Encoder creates a new instance of the Encoder interface that employs the base64 encoding strategy provided by the encoding/base64 package.

func (*Base64Encoder) Decode

func (e *Base64Encoder) Decode(s string) ([]byte, error)

Decode performs base64 URL decoding on the input string using the encoding/base64 package.

func (*Base64Encoder) Encode

func (e *Base64Encoder) Encode(data []byte) (string, error)

Encode performs base64 URL encoding on the input byte slice using the encoding/base64 package.

type Encoder

type Encoder interface {
	Decode(string) ([]byte, error)
	Encode([]byte) (string, error)
}

Encoder is an interface that defines methods for decoding and encoding data.

type NoopEncoder added in v0.1.5

type NoopEncoder struct{}

NoopEncoder is an implementation of the Encoder interface that performs no actual encoding or decoding.

func (NoopEncoder) Decode added in v0.1.5

func (e NoopEncoder) Decode(s string) ([]byte, error)

Decode returns the input string as a byte slice.

func (NoopEncoder) Encode added in v0.1.5

func (e NoopEncoder) Encode(data []byte) (string, error)

Encode returns the input byte slice as a string.

type TokenEncoder added in v0.1.5

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

TokenEncoder combines an encrypter and an encoder to provide functionality for encoding and decoding tokens.

func NewTokenEncoder added in v0.1.5

func NewTokenEncoder(encrypter encrypter.Encrypter, encoder Encoder) *TokenEncoder

NewTokenEncoder constructs a TokenEncoder with the provided encrypter and encoder.

func (*TokenEncoder) Decode added in v0.1.5

func (e *TokenEncoder) Decode(s string) ([]byte, error)

Decode first decodes the input string using its internal decoder, and subsequently decrypts the resulting data using its encrypter.

func (*TokenEncoder) Encode added in v0.1.5

func (e *TokenEncoder) Encode(data []byte) (string, error)

Encode first encrypts the provided data using its internal encrypter, and then encodes the resulting encrypted data using its encoder.

Jump to

Keyboard shortcuts

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