hexkey

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package hexkey implements utilities for hexadecimal encoding of blob store keys.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotMyKey = errors.New("key does not match config")

ErrNotMyKey is a sentinel error reported by Decode when given a key that does not match the parameters of the config.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Prefix, if set, is prepended to all keys, separated from the remainder of
	// the key by "/".
	Prefix string

	// Shard, if positive, specifies a prefix of each hex-encoded key that will
	// be separated from the key by an intervening "/".
	Shard int
}

Config carries settings for the encoding and decoding of hex keys. The zero value is ready for use and encodes keys as plain hexadecimal strings.

func (Config) Decode

func (c Config) Decode(ekey string) (string, error)

Decode decodes the specified hex-encoded key according to c. If ekey does not match the expected format, it reports ErrNotMyKey. Otherwise, any error results from decoding the hexadecimal digits.

func (Config) Encode

func (c Config) Encode(key string) string

Encode encodes the specified key as hexadecimal according to c.

Jump to

Keyboard shortcuts

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