IMHO this makes key much more beautiful than any internal structure.
IMHO this makes key much more beautiful than any internal structure.
https://github.blog/engineering/platform-security/behind-git...
I also like prefixed resource IDs. Stripe is the first one that comes to mind, but I've run into it multiple times where a customer is describing an issue and it turns out the ID they're trying to lookup is for a different resource (often similar). You don't get those accumulated hours of support time back...
Also, I don't really want API keys and such to be generally pretty. If things that have no business being end-user facing are ugly then they are less likely to be allowed to accidentally become end-user facing.
If being pretty or otherwise user-friendly is a priority, then I'd go with trying to make them readable/pronounceable rather than shorter, even if that actually makes them longer. There are numerous projects out there¹²³ for doing just that. You could even use the 256-word example³ with multiple small dictionaries, and give people a choice from various possibilities that map to the same number.
----
[1] https://github.com/Debdut/uuid-readable
Of course, if you like the idea but don’t want to add another dependency, you can copy-paste the three-liner as it is! (And I’m sure it’s not even copyrightable right now :-)
Also requires two other packages to run its 3 lines of code.
"dependencies": { "@scure/base": "^1.1.7", "uuidv7": "^1.0.1" }
E.g.: user_2x4y6z8a0b1c2d3e4f5g6h7j8k