I wasted all my generational luck for this
I wasted all my generational luck for this
I wasted all my generational luck for this
Either this is faked for the meme or something is very very wrong.
I'm leaning heavily towards faked for the meme.
If you actually were trying to get collisions, you'd save all previously generated ids and check all of them for a match with the newest one.
Not only would this increase the chance of a collision (not enough that it should matter, but still), but it would more closely approximate a real use case - if you use UUIDs you're not just in trouble if one specific id is duplicated, it's usually a problem if any id is not unique.
But the presented snippet is simpler and shorter and is close enough to what a naive test might look like, so it's well suited to getting the joke across.
The only way I could imagine this not being fake is if it was achieved in a noncompliant Js implementation. Which seems highly unlikely given the screenshot looks like the Chrome console.
99.999999999999% chance the lava lamp inside your computer is broken.
(The difference from 100% might be my CPU's floating point rounding error)
If it was random once, why shouldn't it be on the 163rd repetition?
An opportunity to share one of my favourite StackOverflow questions of all time!
It's well worth reading through the answers and the comments, but here's a little sampler platter:
This will run for a lot more than hours. Assuming it loops at 1 GHz (which it won't - it will be a lot slower than that), it will run for 10790283070806014188970 years. Which is about 83 billion times longer than the age of the universe.
damn - so maybe serveral threads generating guids is a better idea?
4 threads on a quad core processor would make it run in 20 billion times the age of the universe - so yeah, that would help a lot.
Apparently the guy now works at the federal crime office (bka) in Germany now😂😂
His description is "we all have our segfaults"
figures
is this cryptomining? /s
crypto - as in cryptography, not cryptocurrency - is just the library he's using to generate the 128-bit random UUID. The snippet is interesting because he matched the original UUID in just over 5 hours. You'd expect to need more than 1038 guesses to pick the same number again, which, even at 1 guess every microsecond, means something like 1022 years.
I wanted to downvote you for failing to pick up on the sarcasm, but then you went and did all that math that I was too lazy to do and I ended up upvoting you instead. Damn you!
Sorry, I forgot to add the /s.
But thank you for the calculations, it's actually interesting :) I was thinking about that myself, but didn't bother to do the math.
I thought its reminiscent of cryptomining as it also consist of guessing an arbitrary number just for fun.
This is the fucker who put us on the worst timeline! Get their ass!
I know how I'm heating my office this winter
Please tell this is fake. I want to be ignorant about this.
No problem. It's fake. No need to look deeper.
I don't understand
console.time() jots down the current time, if you do that twice and put stuff in the middle you get two times and the difference between them is how long that stuff took to do
console.timeEnd() uses the last execution of console.time() as the starting point to work out how long the stuff took to do
const originalUUID = crypto.randomUUID() generates a Universally Unique IDentifier, which can be thought of as a very large very random number, by use of a pseudorandom number generator
while(stuff) evaluates the stuff for truthiness (1 + 2 = 5 would be false, 50 < 200 would be true, 'my username starts with the letter k' would be true)
it's typically followed by a 'block' of code, that is lines beginning with { and ending with }, but we don't see that here, which means we can read while(stuff) as "keep checking if stuff is true in an endless loop, and only continue to the next line if one of the checks ends up being false"
the stuff here is creating another random UUID, and checking to see if it's the same random number as the first one generated.
functions like this are so incredibly random that chancing upon two executions creating the same number should be practically impossible. staggeringly impossible. If so this code should never complete, as that while check would be endless, never finding a match
the image suggests that one such match was found in about 19 million milliseconds (a bit over 5 hours). this is probably faked, because the absurd unlikelihood of the same number being generated in so much as a single human lifetime, let alone a day, is laughable
the imagine is faked or something is terribly wrong with their pseudorandom number generator
Insanely unlikely giant random number matches other insanely giant random number
The function first generated a random UUID. This is a long string of random characters, used in many software systems to uniquely fingerprint things, transactions for example. In theory, you can have millions of seperate systems, each generating UUIDs all the time without ever having to worry about a collision (a collision is one or more systems generating the same UUID, therefore it being not unique anymore)
The second line then runs UUID generation again, trying to generate an identical UUID to the one it already made. Tis is absurd because even a dmsupercomputer trying to generate identical UUIDs would take longer than the lifespan of the universe.
The console line shows that a matching UUID was apparently found after some amount of time, which shouldn't be possible, implying some fuckery with the random number generator.
This is probably due to sub standard random numbers. UUIDs are unique. If you manage to duplicate one your doing it badly.
i was curious how unlikely exactly this would be.
The randomUUID method generates a new version 4 UUID
which is, According to the linked documentation, a 128bit number, with some "significant bits" being changed (no idea what that's about, lets just say it's a 128bit number)
the chance of hitting a predfined number would be
1/(2^128) or 1/340282366920938463463374607431768211456
assuming your cpu does one comparison per Step at 4Ghz (4 billion per second) (idk how many steps it needs in reality, it doesn't matter, more then one tho)
that would take roughly
2.696 x 10^21 years, which is
2 x 10^11 or 200000000000 times the age of the universe
(using the expected value of geometric distribution (1/p), so 1/(1/(2^ 128)) = 2^128 steps)
...so your saying theres a chance.
I was able to reproduce this exactly.
brother you're using the wrong thing. First of all you are using crypto that's going to give you some memecoins that are obviously going to collide after 55 hours as what are you even doing not rugpulling the thing day 2?
Second of all, I am pretty sure you should use "RandomUUIDIToldYouSo" module for non-colliding hashes. We all know THAT thing gets its Noise from our parents' instructions on doing a specific thing that keep changing arbitrarily every time you ask.
Only 5.4 hours before you hit a UUID collision. That's insane
Against a apecific one too. Usually you'd check for duplicates against all previous uuids
That would indeed be way (quadratically) more likely but we don't count the number of attempts but measure run time, and since comparisons (even with optimizations like insertion sort) take time, the speed difference between the two methods will be "just" a few orders of magnitude.