crypto

package
v3.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(data []byte, key []byte) ([]byte, error)

Decrypt decrypts the given data using the given passphrase.

func Encrypt

func Encrypt(data []byte, key []byte) ([]byte, error)

Encrypt encrypts the given data with the given passphrase. It uses AES-GCM with a random nonce generated by cipher.NewGCMWithRandomNonce, which, unlike cipher.NewGCM with a caller-supplied nonce, is allowed in FIPS 140-only mode (GODEBUG=fips140=only).

func KeyFromPassphrase

func KeyFromPassphrase(passphrase string) ([]byte, error)

KeyFromPassphrase generates 32 byte key from the passphrase

func KeyFromSecret added in v3.5.10

func KeyFromSecret(secret []byte, info string) ([]byte, error)

KeyFromSecret derives a 32 byte key from a high-entropy secret with HKDF-SHA256. Unlike KeyFromPassphrase (scrypt), HKDF is a FIPS 140-3 approved key derivation function. It does no key stretching, so the secret must already be random, such as the server signature.

Types

This section is empty.

Jump to

Keyboard shortcuts

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