spomky-labs/defuse-generator
A small PHP utility from Spomky-Labs for generating secure cryptographic keys compatible with defuse/php-encryption. It offers a simple API for creating encryption keys to protect application data in Laravel and other PHP projects.
0/O, 1/l/I) or a fixed length.random_bytes(), which Laravel already wraps as Str::random(). Adopting a package here is only justified if it encodes policy you don't want to re-derive (alphabet rules, length validation, timing-safe comparisons, rate-limit-safe entropy sourcing).Adopt only if all of the following hold:
Str::random() and PHP's random_bytes() do not give you out of the box — a constrained alphabet, a checksum, a prefixed key format (sk_live_...), or a decode/validate round-trip.random_bytes/random_int) rather than rand(), mt_rand(), or uniqid().Look elsewhere — or just write the helper — if any of these are true:
Str::random(40) is already a CSPRNG-backed, framework-supported, zero-dependency answer. Introducing a package to replicate it adds supply-chain surface for no capability gain.Password::createToken(), or a signed-URL primitive. A generator is a primitive, not a token system.defuse/php-encryption. The defuse- prefix implies a relationship to that library's Random/Key ecosystem. Confirm whether this is a maintained fork, an experiment, or an unrelated package borrowing the name; a mistaken assumption about lineage is a real supply-chain hazard.Practical PM guidance: timebox a half-day spike, diff the generated output distribution against Str::random(), and if it holds no unique capability, record a "not adopted — covered by framework primitive" decision so the question does not resurface.
For executives (30 seconds): A team member has surfaced a small third-party library that generates random strings — the kind of thing behind password-reset links and API keys. My recommendation is not to adopt it. The capability is already built into our framework (Str::random()), it is backed by the operating system's cryptographic random source, and it carries zero new dependency risk. The proposed package has no stars, no downstream users, and no maintenance trail — that is not a reason it is bad code, but it is a reason we should not put it on a security-sensitive path when we already have an equivalent we control. Cost of the decision: roughly half a day of engineering time to confirm, and no roadmap impact either way. The durable output is a one-line precedent: entropy-touching dependencies need a named owner and a documented fallback.
For engineering: This is not a "no" to the idea, it is a "no" to the dependency. Concretely:
random_bytes() with tests, which we then own outright.Str::random() and stop. It is CSPRNG-backed, framework-supported, and already in every request.mt_rand-derived. Wrapping means swapping it out later costs one file, not a codebase sweep.defuse- prefix suggests lineage with defuse/php-encryption. Confirm that before anyone assumes the security posture transfers.Bottom line: low effort, low risk, near-zero upside. Close it out with a documented decision rather than letting it sit in the backlog as an open question.
How can I help you explore Laravel packages today?