Sqids – Generate short unique IDs from numbers
101–110 of 249 posts
Re: Sqids – Generate short unique IDs from numbers
#102We're using randomly generated strings for many things. IDs, password recovery tokens, etc. We've generated millions of them in our system, for various use-cases. Hundreds of thousands of people see them every day.
I've never heard any complaints about a random content-id being "lR8vDick4r" (dick) or whatever.
But nowadays our society is so afraid of offending anyone, that profanity filters has extended all the way to database IDs and password recovery tokens.
(there are some legit cases, like randomly generated IDs for user profiles shared in public URLs, that users have to live with, but even there just make the min length 8 and you're unlikely to have any full-word profanity as the complete ID; put differently, I don't understand why they made the block list an opt-out thing)
Re: Sqids – Generate short unique IDs from numbers
#103Side note: there are some business insights you can get from a company using serial ids. i.e if you sign up and get user id 32588 and make another account a few days later, you can tell the growth rate of the company. And this is possible with every resource type in the application. I do wonder how much the url bar junk thing matters these days. I tend to use uulids (waiting on uuid v7 wide adoption), and they're a b…
> most browsers Not chrome... Also, links are a thing in chat, etc
> https://www.youtube.com/watch?v=fFMzQ3tYTFU&pp=ygURY2hQImVzZ...
Or Twitter:
> https://x.com/elonmusk/status/172853302828286055507?s=20
Or TikTok:
While I tend to strip the tracking params and there are extensions that do this, I don't think most people do. These URLs are pretty 'ugly'.
So if the links that are being shared most on the internet (YT, TikTok, Twitter) don't care, you probably shouldn't either. I think the onus is on the UI layers (Chat apps, etc) to show urls how they look best on their respective platforms.
Edit: to this point, it looks like HN truncates these to make them less ugly too.
Re: Sqids – Generate short unique IDs from numbers
#104> Not Good For: > User IDs - Can be decoded, revealing user count Suppose you don't want to leak the count, what's a resonable way of implementing that? You can of course have a uuid v7 / uulids or something as the primary key. Or have it as a public facing primary key, mapping back to a sequential ID PK (there might be some performance hits with larger PK's in e.g postgres? or is that just fud?) But you could also g…
Add an offset, multiply by a large prime number, and modulo. I don't think you can recover the original number without figuring out the prime.
Re: Sqids – Generate short unique IDs from numbers
#105Side note: there are some business insights you can get from a company using serial ids. i.e if you sign up and get user id 32588 and make another account a few days later, you can tell the growth rate of the company. And this is possible with every resource type in the application. I do wonder how much the url bar junk thing matters these days. I tend to use uulids (waiting on uuid v7 wide adoption), and they're a b…
Re: Sqids – Generate short unique IDs from numbers
#106Neat library! We're using randomly generated strings for many things. IDs, password recovery tokens, etc. We've generated millions of them in our system, for various use-cases. Hundreds of thousands of people see them every day. I've never heard any complaints about a random content-id being "lR8vDick4r" (dick) or whatever. But nowadays our society is so afraid of offending anyone, that profanity filters has extended…
Re: Sqids – Generate short unique IDs from numbers
#107Neat library! We're using randomly generated strings for many things. IDs, password recovery tokens, etc. We've generated millions of them in our system, for various use-cases. Hundreds of thousands of people see them every day. I've never heard any complaints about a random content-id being "lR8vDick4r" (dick) or whatever. But nowadays our society is so afraid of offending anyone, that profanity filters has extended…
https://github.com/compiler-explorer/compiler-explorer/issue...
Me and you will know it's just random characters, but if HR enters the chat...
Re: Sqids – Generate short unique IDs from numbers
#108I guess they haven't heard of base-64.
That doesn't solve the same set of problems as TFA. Randomized output order for sequential input, skips IDs that include profanity.
Re: Sqids – Generate short unique IDs from numbers
#109Side note: there are some business insights you can get from a company using serial ids. i.e if you sign up and get user id 32588 and make another account a few days later, you can tell the growth rate of the company. And this is possible with every resource type in the application. I do wonder how much the url bar junk thing matters these days. I tend to use uulids (waiting on uuid v7 wide adoption), and they're a b…
Does anyone have an example they can reference of a business being harmed by this information being out there?
Re: Sqids – Generate short unique IDs from numbers
#110I guess they haven't heard of base-64.
That doesn't solve the same set of problems as TFA. Randomized output order for sequential input, skips IDs that include profanity.
> How can I make my IDs unique?
> The library accepts a custom alphabet from which it can generate IDs. Simply pre-shuffle the default alphabet that's provided.
I also have no idea how to use the library.. What are the 3 numbers parameters for encode()? The actual code: https://github.com/sqids/sqids-ruby/blob/main/lib/sqids.rb
I'd simply base-58 a GUID instead. At least you'll know what kind of constraints / sorting the IDs will have.