crypt

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package crypt contains a number of cryptographic functions

Index

Constants

View Source
const (
	Argon2Algo = "Argon2id"
	// Default tuned to process at least 20 API requests/sec on 2CPU
	Argon2Memory     = 64 * 1024 // 64MB
	Argon2Iterations = 1
	Argon2Threads    = 8 // Optimal to quickly execute one request, with not much overhead
	Argon2Saltlen    = 8
	Argon2Hashlen    = 32

	RandStringCharsetB58 = "abcdefghijkmnopqrstuvwxyz" +
		"ABCDEFGHJKLMNPQRSTUVWXYZ123456789" // Base58
	RandStringCharsetAZ = "abcdefghijklmnopqrstuvwxyz" // Only a-z
)

Default parameters for the Argon2 hashing and some charsets usable for representing the data

Variables

This section is empty.

Functions

func GenerateSSHKey added in v0.7.6

func GenerateSSHKey() ([]byte, error)

GenerateSSHKey creates a private key in pem format

func GetSSHPubKeyFromPem added in v0.7.6

func GetSSHPubKeyFromPem(privPem []byte) ([]byte, error)

func InitTLSPairCa added in v0.7.5

func InitTLSPairCa(hosts []string, caPath, keyPath, crtPath string) error

InitTLSPairCa creates a pair of asymmetric keys and CA if needed

func RandBytes

func RandBytes(size int) (data []byte)

RandBytes create random bytes of specified size

func RandString

func RandString(size int) string

RandString generates random string with base58 characters

func RandStringCharset added in v0.7.0

func RandStringCharset(size int, charset string) string

RandStringCharset creates random string of specified size

Types

type Hash

type Hash struct {
	Algo string     `json:"algo"`
	Prop properties `json:"prop"`
	Salt []byte     `json:"salt"`
	Hash []byte     `json:"hash"`
}

Hash contains everything needed for storing and reproducing password hash

func NewHash added in v0.7.5

func NewHash(input string, salt []byte) (h *Hash)

NewHash generates a salted hash for the input string with default parameters

func (*Hash) Deserialize added in v0.7.6

func (h *Hash) Deserialize(jsonHash util.UnparsedJSON) error

func (*Hash) IsEmpty

func (h *Hash) IsEmpty() bool

IsEmpty shows is the hash is actually not filled with data

func (*Hash) IsEqual

func (h *Hash) IsEqual(input string) bool

IsEqual checks the input equal to the current hashed one

func (Hash) Serialize added in v0.7.6

func (h Hash) Serialize() (util.UnparsedJSON, error)

Jump to

Keyboard shortcuts

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