key

package
v2.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

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