fingerprint

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(input string, opts ...Option) ([]byte, error)

Decode decods a fingerprint to the raw bytes.

func Fingerprint

func Fingerprint(input []byte, opts ...Option) string

Fingerprint calculates the fingerprint of the input. By default, the fingerprint is encoded as a hex string without applying any hash algorithm. The behavior can be adjusted by providing the options.

Types

type Encoding

type Encoding int

Encoding represents the fingerprint encoding type.

const (
	// HexFingerprint represents the hex encoding of the fingerprint.
	HexFingerprint Encoding = iota
	// Base64StdFingerprint represents the base64 encoding of the fingerprint.
	Base64StdFingerprint
	// Base64URLFingerprint represents the base64URL encoding of the fingerprint.
	Base64URLFingerprint
	// Base64RawStdFingerprint represents the base64RawStd encoding of the fingerprint.
	Base64RawStdFingerprint
	// Base64RawURLFingerprint represents the base64RawURL encoding of the fingerprint.
	Base64RawURLFingerprint
	// EmojiFingerprint represents the emoji encoding of the fingerprint.
	EmojiFingerprint
)

type Option

type Option func(*options)

Option customizes the fingerprint generation.

func WithEncoding

func WithEncoding(enc Encoding) Option

WithEncoding sets the encoding that is used to generate the fingerprint.

func WithHash

func WithHash(h crypto.Hash) Option

WithHash sets the hashing algorithm that is applied on the input before creating the fingerprint.

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix sets a prefix that is prepended to the generated fingerprint.

Jump to

Keyboard shortcuts

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