userhash

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package userhash provides an obfuscation layer for users in locations.

A userhash allows messages from a given user to be correlated within a channel, but not easily between channels. Specifically, a userhash is based on HMAC with the user ID, channel name, and a value derived from the time as the message content.

The key used to generate hashes must be preserved across program instances.

Userhashes are not intended to guarantee privacy.

Index

Constants

View Source
const Size = 28

Size is the size of a userhash in bytes.

View Source
const TimeQuantum = 15 * time.Minute

TimeQuantum is the duration for which hashing a user and location gives the same result.

Variables

View Source
var (
	// ErrShortHash is an error returned when scanning a userhash that is too
	// short.
	ErrShortHash = errors.New("short userhash")
	// ErrHashType is an error returned when scanning a userhash from a type
	// that cannot be handled.
	ErrHashType = errors.New("bad type for userhash")
)

Functions

This section is empty.

Types

type Hash

type Hash [Size]byte

Hash is an obfuscated hash identifying a user in a location.

type Hasher

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

A Hasher creates Hash values.

func New

func New(prk []byte) Hasher

New creates a Hasher.

func (Hasher) Hash

func (h Hasher) Hash(uid, where string, when time.Time) Hash

Hash computes a userhash.

Jump to

Keyboard shortcuts

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