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 ¶
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.