frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

My adventure in designing API keys

https://vjay15.github.io/blog/apikeys/
32•vjay15•2d ago

Comments

vjay15•2d ago
Hello everyone this is my third blog, I am still a junior learning stuff ^_^
notpushkin•29m ago
Hey, welcome to HN!

Reading “hex” pointing to a clearly base62-ish string was a bit interesting :-)

Also, could we shard based on a short hash of account_id, and store the same hash in the token? This way we can lose the whole api_key → account_id lookup table in the metashard altogether.

calrain•1h ago
I don't like giving away any information what-so-ever in an API key, and would lean towards a UUIDv7 string, just trying to avoid collisions.

Even the random hex with checksum component seems overkill to me, either the API key is correct or it isn't.

andrus•25m ago
GitHub introduced checksums to their tokens to aid offline secret scanning. AFAIK it’s mostly an optimization for that use case. But the checksums also mean you can reveal a token’s prefix and suffix to show a partially redacted token, which has its benefits.
dhruv3006•1h ago
Hey - this was a great blog ! I liked how you used the birthday paradox here.

PS : I too am working on a APIs.Take a look here : https://voiden.md/

usernametaken29•43m ago
I know sometimes people just like to try things out, but for the love of god do not implement encryption related functionality yourself. Use JWT tokens and OpenSSL or another established library to sign them. This problem is solved. Not essentially solved, solved. Creating your own API key system has a high likelihood of fucking things up for good!
fabian2k•36m ago
You don't need any encryption or signing for API keys. Using JWTs is probably more dangerous here, and more annoying for people using the API since you now have to handle refreshing tokens.

Plain old API keys are straightforward to implement. Create a long random string and save it in the DB. When someone connects to the API, check if the API key is in your DB and use that to authenticate them. That's it.

iamflimflam1•29m ago
I would add the capability to be able to seamlessly rotate keys.

But otherwise, yes, for love of everything holy - keep it simple.

notpushkin•35m ago
The securify here comes from looking the key up in the DB, not from any crypto shenanigans.
bob1029•38m ago
I don't understand the need for this level of engineering. It appears we are going for an opaque bearer token here. The checksum is pointless because an entire 512 bit token still fits in an x86 cache line. Comparing the whole sequence won't show up in any profiler session you will ever care about.

If you want aspects of the token to be inspectable by intermediaries, then you want json web tokens or a similar technology. You do not want to conflate these ideas. JWTs would solve the stated database concern. All you need to store in a JWT scheme are the private/public keys. Explicit tracking of the session is not required.

notpushkin•25m ago
> The checksum is pointless because an entire 512 bit token still fits in an x86 cache line

I suppose it’s there to avoid round-trip to the DB. Most of us just need to host the DB on the same machine instead, but given sharding is involved, I assume the product is big enough this is undesirable.

phire•7m ago
You need to support revocation, so I'm not sure it's ever possible to avoid the need for a round trip to verify the token.
ramchip•20m ago
The purpose of the checksum is to help secret scanners avoid false positives, not to optimize the (extremely rare) case where an API key has a typo
weitendorf•15m ago
Hey OP, sorry for the negativity, I think most of these commenters right now are pretty off-base. My company is building a lot of API infrastructure and I thought this was a great write up!
Savageman•4m ago
Side note: the slug is not primarily intended for the end-user / developer to figure out which kind of key it is, but for security scanners to detect when they are committed to code / leaked and invalidate them.

Peter Steinberger – WhatsApp CLI: sync, search, send

https://github.com/steipete/wacli
45•dinakars777•1h ago•21 comments

Fixing a 20-year-old bug in Enlightenment E16

https://iczelia.net/posts/e16-20-year-old-bug/
87•snoofydude•3h ago•15 comments

My adventure in designing API keys

https://vjay15.github.io/blog/apikeys/
33•vjay15•2d ago•16 comments

Claude Code Routines

https://code.claude.com/docs/en/routines
585•matthieu_bl•15h ago•345 comments

Founders Need to Be Ruthless When Chasing Deals

https://steveblank.com/2024/04/16/founders-need-to-be-ruthless-when-chasing-deals/
18•tie-in•3d ago•2 comments

Not all elementary functions can be expressed with exp-minus-log

https://www.stylewarning.com/posts/not-all-elementary/
89•mmastrac•6h ago•51 comments

Dependency cooldowns turn you into a free-rider

https://calpaterson.com/deps.html
103•pabs3•6h ago•59 comments

MDalgorithms (AI Healthcare) – Hiring Growth Marketer – Remote – $80K-$140K

https://www.ycombinator.com/companies/mdalgorithms-inc/jobs/LVODKN7-growth-marketer-for-a-rapidly...
1•odedharth93•1h ago

Rare concert recordings are landing on the Internet Archive

https://techcrunch.com/2026/04/13/thousands-of-rare-concert-recordings-are-landing-on-the-interne...
631•jrm-veris•18h ago•180 comments

Amazon to acquire Globalstar and expand Amazon Leo satellite network

https://www.businesswire.com/news/home/20260414237496/en/Amazon-to-Acquire-Globalstar-and-Expand-...
43•homarp•2h ago•15 comments

My AI-Assisted Workflow

https://www.maiobarbero.dev/articles/ai-assisted-workflow/
3•maiobarbero•57m ago•0 comments

A communist Apple II and fourteen years of not knowing what you're testing

https://llama.gs/blog/index.php/2026/04/10/friday-archaeology-a-communist-apple-ii-and-fourteen-y...
148•major4x•4d ago•25 comments

The Orange Pi 6 Plus

https://taoofmac.com/space/reviews/2026/04/11/1900
182•rcarmo•3d ago•131 comments

Installing OpenBSD on the Pomera DM250 Writerdeck

https://jcs.org/2026/04/09/openbsd-dm250
32•djfergus•4d ago•8 comments

Stop Flock

https://stopflock.com
614•cdrnsf•10h ago•154 comments

Picasso’s Guernica (Gigapixel)

https://guernica.museoreinasofia.es/gigapixel/#3/63.11/-120.59
113•guigar•3d ago•31 comments

Understanding Clojure's Persistent Vectors, pt. 1 (2013)

https://hypirion.com/musings/understanding-persistent-vector-pt-1
72•mirzap•4d ago•11 comments

5NF and Database Design

https://kb.databasedesignbook.com/posts/5nf/
157•petalmind•15h ago•59 comments

Turn your best AI prompts into one-click tools in Chrome

https://blog.google/products-and-platforms/products/chrome/skills-in-chrome/
156•xnx•14h ago•77 comments

PCBWay sponsorship: full-size SD module for Arduino projects

https://www.colino.net/wordpress/archives/2026/04/10/pcbway-sponsorship-full-size-sd-module-for-a...
16•ibobev•4d ago•8 comments

Let's talk space toilets

https://mceglowski.substack.com/p/lets-talk-space-toilets
173•zdw•1d ago•49 comments

The dangers of California's legislation to censor 3D printing

https://www.eff.org/deeplinks/2026/04/dangers-californias-legislation-censor-3d-printing
374•salkahfi•1d ago•357 comments

Tell HN: Fiverr left customer files public and searchable

596•morpheuskafka•13h ago•130 comments

Trusted access for the next era of cyber defense

https://openai.com/index/scaling-trusted-access-for-cyber-defense/
76•surprisetalk•11h ago•52 comments

Guide.world: A compendium of travel guides

https://guide.world/
105•firloop•5d ago•17 comments

Saying goodbye to Agile

https://lewiscampbell.tech/blog/260414.html
117•matrixhelix•3h ago•133 comments

I wrote to Flock's privacy contact to opt out of their domestic spying program

https://honeypot.net/2026/04/14/i-wrote-to-flocks-privacy.html
595•speckx•14h ago•236 comments

Game: Print Gallery Of An Artist, A brief exploration of recursive spaces

https://managore.itch.io/print-gallery-of-an-artist
18•zdw•4d ago•3 comments

Troubleshooting Email Delivery to Microsoft Users

https://rozumem.xyz/posts/14
70•rozumem•2d ago•17 comments

Introspective Diffusion Language Models

https://introspective-diffusion.github.io/
264•zagwdt•1d ago•46 comments