hashref

package
v0.0.0-...-8e4e7ff Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hash      = 0
	Text      = 1
	File      = 2
	Publisher = 3
)

Variables

View Source
var Lookup = map[HashType]string{Hash: "hash", Text: "text", File: "file", Publisher: "publisher"}

Functions

func CalculateHash

func CalculateHash(raw []byte) string

CalculateHash calculates the sha256 hashsum to a provided byte slice

func GetJsonFields

func GetJsonFields() (fields []string)

GetJsonFields returns a slice of strings with json field names for a Config object

Types

type Config

type Config struct {
	Publisher     string            `json:"HASHREF_PUBLISHER"`
	DefaultMeta   map[string]string `json:"HASHREF_DEFAULT_META"`
	HashrefServer string            `json:"HASHREF_SERVER"`
}

func LoadConfig

func LoadConfig(cfgFileName string) Config

LoadConfig loads the configuration from the provided file path

func NewConfig

func NewConfig() Config

NewConfig returns a Config object with default values

func (*Config) LoadEnvValues

func (c *Config) LoadEnvValues()

LoadEnvValues loads Config object values based on the json field names from the environment

type HashType

type HashType int

func GetHashTypeAndValue

func GetHashTypeAndValue(input string) (HashType, string)

GetHashTypeAndValue identifies if the provided input is a text, file or sha256 hashsum

type HashrefClient

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

func NewClient

func NewClient(config Config) HashrefClient

func (*HashrefClient) CollectLocalMetadata

func (hc *HashrefClient) CollectLocalMetadata(inputType HashType, input, hash string) map[string]interface{}

CollectLocalMetadata collects based on the provided input metadata and returns it as a map with metadata

func (*HashrefClient) GetRemoteData

func (hc *HashrefClient) GetRemoteData(inputType HashType, input, hashValue string) (bool, map[string]interface{})

func (*HashrefClient) GetRemoteDataFromPublisher

func (hc *HashrefClient) GetRemoteDataFromPublisher(inputType HashType, input, hashValue, publisher string) (bool, map[string]interface{})

func (*HashrefClient) GetSelf

func (hc *HashrefClient) GetSelf() map[string]interface{}

GetSelf performs a request to the server and collects the metadata that is stored remotly to the publisher

func (*HashrefClient) RemoveHash

func (hc *HashrefClient) RemoveHash(force bool, input, calculatedHash string) bool

RemoveHash deletes the metadata remotly to the provided hash.

func (*HashrefClient) SetRemoteData

func (hc *HashrefClient) SetRemoteData(inputType HashType, input string, calculatedHash string, metadata map[string]interface{}) bool

func (*HashrefClient) SetSelf

func (hc *HashrefClient) SetSelf(metadata map[string]interface{}) bool

SetSelf sets the metadata to the hash of the identity remoely

Jump to

Keyboard shortcuts

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