You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,13 @@
2
2
3
3
All notable changes to this project will be documented in this file.
4
4
5
+
## v0.2.0 - 2026-01-17
6
+
- Added policy presets (`PolicyInteractive`, `PolicyModerate`, `PolicySensitive`) plus the `WithPolicy` option for configuring Argon2id without manual parameters.
7
+
- Introduced `argon2.ParamsForPolicy` and a shared policy descriptor so the CLI and library reuse the same vetted defaults.
8
+
- Hardened `argon2.Argon2idHasher` with parameter validation guards and augmented doc comments across the new public surface.
9
+
- Expanded the test suite to cover policy selection and the Argon2 preset helpers, keeping `go test ./...` green.
10
+
- Rewrote README to state the Argon2id-only stance and document the policy workflow.
11
+
5
12
## v0.1.0 - 2026-01-17
6
13
- Initial public release of `go-pwdhash` with Argon2id defaults (64MiB memory, 3 iterations, 4 lanes, 16-byte salts, 32-byte keys).
7
14
- Introduced PHC-compliant encoder/decoder plus constant-time comparison helpers.
Copy file name to clipboardExpand all lines: README.md
+36-24Lines changed: 36 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,35 @@
1
1
# go-pwdhash
2
2
3
-
`go-pwdhash` is a Go-first implementation of the Password Hashing Competition (PHC) string format with a batteries-included Argon2id hasher, deterministic upgrade signals, and zero surprises for callers who need predictable password hygiene.
3
+
`go-pwdhash` is a Go-first password hashing helper that embraces the PHC (Password Hashing Competition) format, wraps Argon2id with safe defaults, and surfaces a minimal API for hashing, verification, and upgrades.
4
+
5
+
## Argon2id Only
6
+
7
+
pwdhash intentionally supports **Argon2id only**. Algorithms that have already been superseded by Argon2id will not be added, reducing the chance of accidentally selecting outdated primitives. If a superior successor to Argon2id emerges, pwdhash will adopt it behind the same API surface.
8
+
9
+
## Password Policies
10
+
11
+
pwdhash ships with opinionated Argon2id policies so applications can select a strength profile without touching raw parameters:
12
+
13
+
-**Interactive** – user login flows where latency matters most.
14
+
-**Moderate** – API keys, service-to-service calls, and privileged automation.
15
+
-**Sensitive** – infrastructure secrets, root accounts, and long-lived credentials.
16
+
17
+
Policies prevent insecure configurations by clamping the underlying Argon2id memory, iteration, and parallelism values to vetted presets.
4
18
5
19
## Highlights
6
20
7
-
-**Modern Argon2id defaults** – ships with 64MiB memory, 3 iterations, 4 lanes, 16-byte salts, 32-byte keys, and Argon2 v=19 metadata.
8
-
-**PHC compliant outputs** – hashes look like `$argon2id$v=19$...` and round-trip cleanly through the built-in parser.
9
-
-**Interoperable by design** – encoded hashes verify inside Python's `pwdlib` and equivalent implementations in Rust or C without adapters.
10
-
-**Extensible registry** – inject alternative hashers (or tuned Argon2id instances) via options while keeping a single entry point.
11
-
-**Deterministic lifecycle** – `Hash`, `Verify`, and `NeedsRehash` expose the minimum API you need to manage password upgrades.
-**PHC-compliant output** – hashes look like `$argon2id$v=19$...` and parse cleanly across ecosystems.
22
+
-**Deterministic upgrade path** – `NeedsRehash` compares stored parameters to the active policy so callers know exactly when to re-encode.
23
+
-**Extensible registry** – advanced users may inject tuned Argon2id instances or alternate hashers via the option system.
24
+
-**Constant-time verification** – comparisons use helpers under `internal/subtle` to avoid timing leaks.
13
25
14
26
## Installation
15
27
16
28
```bash
17
29
go get github.com/allisson/go-pwdhash
18
30
```
19
31
20
-
The module targets Go 1.24, depends on `golang.org/x/crypto`, and uses `stretchr/testify`only for tests.
32
+
The module targets Go 1.24, depends on `golang.org/x/crypto`, and uses `stretchr/testify`solely for tests.
21
33
22
34
## Quick Start
23
35
@@ -31,7 +43,9 @@ import (
31
43
)
32
44
33
45
funcmain() {
34
-
hasher, err:= pwdhash.New()
46
+
hasher, err:= pwdhash.New(
47
+
pwdhash.WithPolicy(pwdhash.PolicyInteractive),
48
+
)
35
49
if err != nil {
36
50
panic(err)
37
51
}
@@ -57,7 +71,12 @@ func main() {
57
71
58
72
## Configuration
59
73
60
-
`pwdhash.New` accepts functional options. By default it registers a single Argon2id hasher returned by `argon2.Default()`. To tune parameters, construct the hasher yourself and inject it:
74
+
`pwdhash.New` accepts functional options:
75
+
76
+
-`pwdhash.WithPolicy` selects one of the built-in presets.
77
+
-`pwdhash.WithHasher` installs a custom `pwdhash.Hasher` (useful for bespoke Argon2id tuning or for experimenting with future algorithms).
To introduce a new algorithm, implement the `pwdhash.Hasher` interface and register it through `WithHasher`. The password hasher keeps an internal registry keyed by `Hasher.ID()`, so mixed fleets of algorithms are possible during migrations.
82
-
83
-
## PHC Encoding Basics
100
+
## PHC Encoding
84
101
85
-
Internally, the library serializes `encoding.EncodedHash`structures that follow the pattern:
102
+
pwdhash serializes `encoding.EncodedHash`values using the canonical PHC layout:
0 commit comments