key

package
v2.52.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// FlagDefault marks API keys for default (community) accounts.
	FlagDefault = 0x0000
	// FlagScienceMesh marks API keys for ScienceMesh (partner) accounts.
	FlagScienceMesh = 0x0001
)

Variables

This section is empty.

Functions

func SaltFromEmail

func SaltFromEmail(email string) string

SaltFromEmail generates a salt-value from an email address.

func SplitAPIKey

func SplitAPIKey(apiKey APIKey) (string, int, string, error)

SplitAPIKey splits an API key into its pieces: RandomString, Flags and Hash.

func VerifyAPIKey

func VerifyAPIKey(apiKey APIKey, salt string) error

VerifyAPIKey checks if the API key is valid given the specified salt value.

Types

type APIKey

type APIKey = string

APIKey is the type used to store API keys.

func GenerateAPIKey

func GenerateAPIKey(salt string, flags int) (APIKey, error)

GenerateAPIKey generates a new (random) API key which also contains flags and a (salted) hash. An API key has the following format: <RandomString:30><Flags:2><SaltedHash:32>

type SiteIdentifier

type SiteIdentifier = string

SiteIdentifier is the type used to store site identifiers.

func CalculateSiteID

func CalculateSiteID(apiKey APIKey, salt string) (SiteIdentifier, error)

CalculateSiteID calculates a (stable) site ID from the given API key. The site ID is actually the CRC64 hash of the provided API key plus a salt value, thus it is stable for any given key & salt pair.

Jump to

Keyboard shortcuts

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