Do we really need a library for that? Shouldn't it be a simple function?
Sqids – Generate short unique IDs from numbers
221–230 of 249 posts
Re: Sqids – Generate short unique IDs from numbers
#222I don't get it, that's like two lines of code, why does it have a library and even a domain
Yes, it's not that complicated (about 160 lines of low-density python), but it's portable, and portable, reusable code goes into libraries.
Re: Sqids – Generate short unique IDs from numbers
#223Earlier quoted context omitted.
You can extract the timestamp from UUID7/8 so it also can reveal business information.
That's why I'm asking, it seems like a liability.
There are probably some business cases where the “when” information is potentially useful (I cant think of any) but, you cant know, for example, how many users are in the database.
Re: Sqids – Generate short unique IDs from numbers
#224Earlier quoted context omitted.
> If you don't override it, then your IDs won't decode right when you update. They'll decode fine. Encoding might change.
I think your right, but that violates the uniqueness guarantee. It doesnt seem like something that should change over time by default.
Re: Sqids – Generate short unique IDs from numbers
#225Earlier quoted context omitted.
No, squids are predictable, you can't use them to hide information. They call it out on their front page.
I haven't looked at the implementation yet but HashIds (the former project name) required a salt. It would be weird if they changed that.
Obfuscated
Re: Sqids – Generate short unique IDs from numbers
#226Earlier quoted context omitted.
That's why I'm asking, it seems like a liability.
You don't get the cardinality of the data type, just when the object was created. There are probably some business cases where the “when” information is potentially useful (I cant think of any) but, you cant know, for example, how many users are in the database.
It can make sense for some situational internal database use case where you want temporal locality and can't use full sequential since it's distributed, and even then your DBMS might recommend something else, e.g. Spanner explicitly says not to do this. And it doesn't need to be exposed to users.
Re: Sqids – Generate short unique IDs from numbers
#227I appreciate that the author clearly states that security, i.e., output can't be reversed back to the input, is a non-requirement. We can't criticize the author too much for that either, because, as a rule, "random-looking id generator" algorithms will always be either not secure, or not short, or not collision-free. Or they'll be a key-value database. A secure "random-looking id generator" is called a block cipher.…
Re: Sqids – Generate short unique IDs from numbers
#228Earlier quoted context omitted.
Yeah don’t forget the bad words filter. I worked on an IKEA mailing where the list processing house was adding an autogenerated discount code to the address label. The customers received codes with BOOB, DICK, TWAT, and CUNT embedded within. People were not happy.
Did they never make an IKEA purchase after that or did they get over it like a normal adult? I don't work retail, but something tells me people will make a stink out of just about anything if it meant potentially free products or other compensation. Plus, are you filtering just English curse words or all curse words for countries that use Latin characters?
The mailing house that did the work was fired though.
Re: Sqids – Generate short unique IDs from numbers
#229Earlier quoted context omitted.
> that'll be like trying to determine the average salary in a company with only two known ones, which could be the janitor's and the CEO's Ironically that would be somewhat close to the actual average.
It would be significantly above the average unless the company is ridiculously top-heavy or has shockingly little variation in salary. Or if the "salary" for the CEO ignores certain compensation (eg: paid a salary of $1 + stock options).