cryptotest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package cryptotest provides test-only helpers for the crypto package, following the convention of the standard library's httptest.

Nothing here may be used by production code. A composition root builds its hasher from crypto.DefaultParams; a build that reaches this package outside a test has selected deliberately breakable parameters.

Example

Example demonstrates a consuming application's test suite hashing and verifying a password with cryptotest's cheap, non-production cost parameters, exercised entirely through crypto's public API.

package main

import (
	"fmt"

	"github.com/ericfisherdev/nestcore/crypto"
	"github.com/ericfisherdev/nestcore/crypto/cryptotest"
)

func main() {
	hasher := cryptotest.Hasher()

	encoded, err := hasher.Hash("correct-horse-battery-staple")
	if err != nil {
		fmt.Println("hash error:", err)
		return
	}

	ok, err := crypto.Verify("correct-horse-battery-staple", encoded)
	if err != nil {
		fmt.Println("verify error:", err)
		return
	}
	fmt.Println(ok)
}
Output:
true

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hasher

func Hasher() *crypto.Hasher

Hasher returns an argon2id hasher with cheap, test-only cost parameters.

Hashes it produces verify correctly through the ordinary crypto.Verify path: the cost parameters are recorded in the PHC-encoded string and read back on verification, so cheaply-hashed fixtures and production hashes are handled by exactly the same code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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