idf

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: BSD-2-Clause Imports: 4 Imported by: 2

Documentation

Overview

The package idf contains the structure of the ID File. It holds a generated ID and a salt (a 256-bit random number) in a JSON file. This file is used by different entities to save their ID and salt to file. The file path is usually stored and referenced from each entity's configuration files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadIDF

func LoadIDF(filePath string, salt []byte, genID *id.ID) error

MarshalIdfToJSON creates an IdFile object with the provided values and marshals it into JSON bytes ready to be written to a file.

func UnloadIDF

func UnloadIDF(filePath string) ([]byte, *id.ID, error)

UnloadIDF reads the contents of the IDF at the given path and returns the salt and ID stored in it. It does so by unmarshalling the JSON in the file into an IdFile object. The ID bytes from the object are unmarshalled into an ID object and it is returned along with the salt.

Errors are returned when there is a failure to read the IDF, unmarshall the JSON, or unmarshalling the ID.

Types

type IdFile

type IdFile struct {
	ID      string            `json:"id"`
	Type    string            `json:"type"`
	Salt    [saltLen]byte     `json:"salt"`
	IdBytes [id.ArrIDLen]byte `json:"idBytes"`
}

IdFile structure matches the JSON structure used to save IDs and salts. The ID and ID type are saved as strings to make the file easy to read; they are never used or processed.

Jump to

Keyboard shortcuts

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