util

package
v0.0.0-...-a6a622b Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawTree

func DrawTree(ms TraversableMapStore, root []byte, options DrawTreeOptions) (*graphviz.Graphviz, *cgraph.Graph, error)

DrawTree draws a graphviz tree starting at the given root.

func FindLogs

func FindLogs(input string) []*loglist2.Log

FindLogs is similar to loglist2.LogList.FuzzyFindLog, but also tries to use search by strings.lower(input) in the case of URLs.

func GetLogList

func GetLogList() *loglist2.LogList

GetLogList returns a fixed log list that is loaded from an embeded file. The returned loglist is the same throughout the runtime of the program and should therefore not be modified.

func HashBytes

func HashBytes(bs ...[]byte) []byte

HashBytes returns the sha256 hash of the given bytes

func HashBytesFixed

func HashBytesFixed(bs ...[]byte) ct.SHA256Hash

HashBytesFixed returns the sha256 hash of the given bytes in a fixed size array

func NewTruncatedSHA256

func NewTruncatedSHA256(size int) hash.Hash

NewTruncatedSHA256 creates a new TruncatedHash using sha256 as its base hash. Equivalent to calling TruncateHash(sha256.New(), size).

func NormalizeDomainName

func NormalizeDomainName(rawName string) (string, error)

NormalizeDomainName puts a domain name in normalized form

func RandomBase64String

func RandomBase64String(length int) string

RandomBase64String creates a random base64 string of the specified length.

func TruncateHash

func TruncateHash(base hash.Hash, size int) hash.Hash

TruncateHash creates a new TruncatedHash from the base hash with the given size. After calling TruncateHash(base, size), base should no longer be used by external code.

Types

type DrawTreeOptions

type DrawTreeOptions struct {
	MaxHashLength     int
	FormatHashesAsHex bool
	ValueFormatter    func(leafPath, leafHash, valueHash, value []byte) string
}

DrawTreeOptions is used to specify options to DrawTree

type TraversableMapStore

type TraversableMapStore interface {
	smt.MapStore
	TraverseNodes(root []byte, nodeFn mapstore.NodeHandler, leafFn mapstore.LeafHandler) error
}

A TraversableMapStore is a map store which can be traversed.

func MapStoreFromLeaves

func MapStoreFromLeaves(leaves []uint64) (TraversableMapStore, []byte)

MapStoreFromLeaves creates a traversable map store from a slice of leaves. This MapStore is extremely limited an supports only traversal and Get(n) of leaf values.

Returns the map store and the root node

type TruncatedHash

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

A TruncatedHash is a truncated version of longer hashes. Used for testing purposes

func (*TruncatedHash) BlockSize

func (sh *TruncatedHash) BlockSize() int

BlockSize returns the hash's underlying block size. The Write method must be able to accept any amount of data, but it may operate more efficiently if all writes are a multiple of the block size.

func (*TruncatedHash) Reset

func (sh *TruncatedHash) Reset()

Reset resets the Hash to its initial state.

func (*TruncatedHash) Size

func (sh *TruncatedHash) Size() int

Size returns the number of bytes Sum will return.

func (*TruncatedHash) Sum

func (sh *TruncatedHash) Sum(b []byte) []byte

Sum appends the current hash to b and returns the resulting slice. It does not change the underlying hash state.

func (*TruncatedHash) Write

func (sh *TruncatedHash) Write(p []byte) (n int, err error)

Write adds more data to the running hash. It never returns an error.

Jump to

Keyboard shortcuts

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