"RokuMarkn" wrote:
In many applications, one does not have access to all previously generated GUIDs, but I can't say if that's true for the OP.
If Rnd returned truly random numbers, TheEndless' algorithm would be pretty much as good as a real GUID. It's possible, although extremely unlikely, for real GUIDs, produced according to the RFC, to produce duplicates too. In TheEndless' algorithm, since Rnd is called in a predictable sequence, collisions are only as unlikely as two scripts starting with the same Rnd internal state, which actually isn't all that unlikely. Rnd is not a cryptographically strong RNG and it's probably not a good idea to use it as such.
--Mark
Mark, what is the seed for Rnd on the Roku? I assumed it would be the current tick (or something as equally high resolution), in which case, the likelihood of duplicate generation across a 32 character sequence seems
extremely unlikely.
Your point about Rnd not being cryptographically strong is understood, but the OP just said he needed a unique ID in the form of a GUID. He never really expanded on why he needed them, hence my question about why he'd be generating them often enough that duplication was a concern.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)