codec

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version1 = "v1.0.0" // Original version using hex encoding
	Version2 = "v2.0.0" // New version using base64 encoding (not backward compatible with v1)
)

Version constants

Variables

This section is empty.

Functions

func DecodeParams

func DecodeParams(params string) (map[string]string, error)

func EncodeParams

func EncodeParams(params map[string]string) string

EncodeParams encodes a map of parameters into a string. It sorts the keys to ensure a consistent output string.

func MergeParams added in v1.1.0

func MergeParams(sources string, params map[string]string) string

Types

type Codec

type Codec interface {
	Encoder
	Decoder
	Version
}

Codec defines the interface for hash encoding and decoding operations

func NewCodec

func NewCodec(opts ...Option) Codec

NewCodec creates a new codec

type Decoder added in v1.1.0

type Decoder interface {
	// Decode decodes a string into hash parts
	Decode(encoded string) (*types.HashParts, error)
}

Decoder defines the interface for hash decoding operations

type Encoder added in v1.1.0

type Encoder interface {
	// Encode encodes salt and hash into a string
	Encode(parts *types.HashParts) (string, error)
}

Encoder defines the interface for hash encoding operations

type Option

type Option func(*codec)

Option defines configuration options for the codec

func WithVersion

func WithVersion(version string) Option

WithVersion sets the version number Use Version1 (v1.0.0) for hex encoding (legacy) Use Version2 (v2.0.0) for base64 encoding (recommended for new hashes) Follows semantic versioning (semver.org)

type Version added in v1.1.0

type Version interface {
	// Version returns the version of the codec
	Version() string
}

Version defines the interface for version operations

Jump to

Keyboard shortcuts

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