larzapikey
Generate and verify opaque API keys the right way.
Store hash(key), never the raw key - the same discipline password handling uses, upgraded to real SHA-256 via the crypto package instead of a demo checksum. generate()'s randomness is seeded from the monotonic clock, not a real OS entropy source - fine for dev/demo keys, not a substitute for a true CSPRNG in production.
larzscript pkg install apikey
What you get
- Real SHA-256 hashing via crypto
- Store the hash, never the raw key
- Optional prefix ("sk_...") for at-a-glance identification
- Clock-seeded randomness - dev/demo only, not a CSPRNG
Try it
import "apikey" as apikey
let key = apikey.generate("sk")
print(len(key) > 10, key.starts_with("sk_"))
let stored = apikey.hash(key)
print(apikey.verify(key, stored))
print(apikey.verify("wrong-key", stored))Output
true true true false
Why it's in the Larz Stack
larzapikey is a real Larzscript package (larzscript pkg install apikey) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.