Live data from Hacker News

Sqids – Generate short unique IDs from numbers

sqids.org

221–230 of 249 posts

Re: Sqids – Generate short unique IDs from numbers

#222

I don't get it, that's like two lines of code, why does it have a library and even a domain

What I don't get is that you can see the code, and it is clearly more than two lines, but you still claim that it's two lines of code.

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

#223
post #185

Earlier 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.

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.

Re: Sqids – Generate short unique IDs from numbers

#224

Earlier 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.

There explicitly is no uniqueness guarantee. It is known that the same values can encode into many different strings, and they recommend always decoding then reencoding with a stable algorithm to achieve a "canonical" id if one is needed.

https://sqids.org/faq#valid-ids

Re: Sqids – Generate short unique IDs from numbers

#225

Earlier 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.

They're weakly unpredictable.

Obfuscated

Re: Sqids – Generate short unique IDs from numbers

#226

Earlier 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's usually benign, but why encode any info into your public IDs? I wouldn't go anywhere near that.

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

#227
post #191

I 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.…

I realize now the site lists "One-Time Passwords" as a use-case. I'm a positive-vibes-only HN poster though, so will leave it as an exercise to the reader to decide whether that's going to turn out well or not.

Re: Sqids – Generate short unique IDs from numbers

#228

Earlier 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?

We caught it about 2 million into a 15 million print run. I had to go through the control files and change the offending value or identify the pallet and bundle of mail it was in so we could remove and readdress the catalog. It was about 10 years ago and anyone who complained got a coupon.

The mailing house that did the work was fired though.

Re: Sqids – Generate short unique IDs from numbers

#229
post #168

Earlier 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).

Sure thing. I could have worded it better, but I was trying to say that it would be much more skewed if the two samples were, say, CEO and the CFO, or two janitors.
Post reply on HN