crypto

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPassphraseBytes is the number of random bytes for passphrase generation.
	// 32 bytes = 256 bits of entropy, encoded as ~43 base64 characters.
	DefaultPassphraseBytes = 32
)

Variables

This section is empty.

Functions

func GeneratePassphrase

func GeneratePassphrase(numBytes int) (string, error)

GeneratePassphrase creates a cryptographically secure passphrase. The passphrase is URL-safe base64 encoded (no padding) for easy handling.

func GenerateRawPassphrase added in v0.0.8

func GenerateRawPassphrase(numBytes int) (raw []byte, passphrase string, err error)

GenerateRawPassphrase creates random bytes and returns both the raw bytes and the base64url-encoded passphrase string. Protocol v2 splits the raw bytes via Shamir (instead of the encoded string), then base64url-encodes after recombining. The passphrase string is used for age encryption.

func HashFile

func HashFile(path string) (string, error)

HashFile returns the SHA-256 hash of a file, prefixed with "sha256:". This function requires file system access and is not available in WASM.

Types

This section is empty.

Jump to

Keyboard shortcuts

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