Documentation
¶
Index ¶
- func ComparePasswordAndHash(password, encodedHash string) (bool, error)
- func CreateArgon2Hash(password string) (string, error)
- func DerefPtr[T any](p *T, defaultValue T) T
- func GetMachineID() string
- func HashSHA256Hex(data []byte) string
- func HashStringSHA256Hex(value string) string
- func InitArgon2idParams(param Argon2idParams)
- func InitRSAPrivateKey(pemStr string) (*rsa.PrivateKey, error)
- func IsArgon2Hash(s string) bool
- func MongoCleanup(mongodbClient *mongo.Client, dbName string) error
- func PEMToRSAPublicKey(pemBytes string) (*rsa.PublicKey, error)
- func Ptr[T any](v T) *T
- func RSAPublicKeyToPEM(pub *rsa.PublicKey) ([]byte, error)
- type Argon2idParams
- type GenericMap
- func (m *GenericMap[K, V]) Clear()
- func (m *GenericMap[K, V]) CompareAndDelete(key K, old V) (deleted bool)
- func (m *GenericMap[K, V]) CompareAndSwap(key K, old, new V) (swapped bool)
- func (m *GenericMap[K, V]) Delete(key K)
- func (m *GenericMap[K, V]) Load(key K) (value V, ok bool)
- func (m *GenericMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)
- func (m *GenericMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
- func (m *GenericMap[K, V]) Range(f func(key K, value V) bool)
- func (m *GenericMap[K, V]) Store(key K, value V)
- func (m *GenericMap[K, V]) Swap(key K, value V) (previous V, loaded bool)
- type MerkleNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparePasswordAndHash ¶
func CreateArgon2Hash ¶
func GetMachineID ¶
func GetMachineID() string
func HashSHA256Hex ¶ added in v1.2.0
func HashStringSHA256Hex ¶ added in v1.2.0
func InitArgon2idParams ¶
func InitArgon2idParams(param Argon2idParams)
func InitRSAPrivateKey ¶
func InitRSAPrivateKey(pemStr string) (*rsa.PrivateKey, error)
func IsArgon2Hash ¶
Types ¶
type Argon2idParams ¶
type GenericMap ¶
type GenericMap[K comparable, V any] struct { // contains filtered or unexported fields }
GenericMap is a concurrent safe map with generic key and value types.
func NewGenericMap ¶
func NewGenericMap[K comparable, V any]() *GenericMap[K, V]
NewGenericMap creates a new instance of GenericMap.
func (*GenericMap[K, V]) Clear ¶
func (m *GenericMap[K, V]) Clear()
Clear deletes all the entries, resulting in an empty Map.
func (*GenericMap[K, V]) CompareAndDelete ¶
func (m *GenericMap[K, V]) CompareAndDelete(key K, old V) (deleted bool)
CompareAndDelete deletes the entry for key if its value is equal to old. The old value must be of a comparable type.
If there is no current value for key in the map, CompareAndDelete returns false (even if the old value is the nil interface value).
func (*GenericMap[K, V]) CompareAndSwap ¶
func (m *GenericMap[K, V]) CompareAndSwap(key K, old, new V) (swapped bool)
CompareAndSwap swaps the old and new values for key if the value stored in the map is equal to old. The old value must be of a comparable type.
func (*GenericMap[K, V]) Delete ¶
func (m *GenericMap[K, V]) Delete(key K)
Delete deletes the value for a key.
func (*GenericMap[K, V]) Load ¶
func (m *GenericMap[K, V]) Load(key K) (value V, ok bool)
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*GenericMap[K, V]) LoadAndDelete ¶
func (m *GenericMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*GenericMap[K, V]) LoadOrStore ¶
func (m *GenericMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (*GenericMap[K, V]) Range ¶
func (m *GenericMap[K, V]) Range(f func(key K, value V) bool)
func (*GenericMap[K, V]) Store ¶
func (m *GenericMap[K, V]) Store(key K, value V)
Store sets the value for a key.
func (*GenericMap[K, V]) Swap ¶
func (m *GenericMap[K, V]) Swap(key K, value V) (previous V, loaded bool)
Swap swaps the value for a key and returns the previous value if any. The loaded result reports whether the key was present.
type MerkleNode ¶ added in v1.2.0
type MerkleNode struct {
Hash string
Left *MerkleNode
Right *MerkleNode
}
func BuildMerkleTree ¶ added in v1.2.0
func BuildMerkleTree(leafHashes []string) *MerkleNode
func FindMerkleNode ¶ added in v1.2.0
func FindMerkleNode(root *MerkleNode, hash string) *MerkleNode
func TruncateMerkleTree ¶ added in v1.2.0
func TruncateMerkleTree(root *MerkleNode, depth int64) *MerkleNode