top | item 15902116

(no title)

onetwotree | 8 years ago

I'm with you 100% that this is silly, show-off-y code golf at its worst. The fact that its purporting to generate something a bit sensitive (why else would you use the awkward `crypto.getRandomValues` interface?) is especially troublesome - sensitive code should be clear at all costs.

I spent a bit longer than 30 seconds looking at it though, and I think the 8 is actually significant - according to the RFC,

> "Set the two most significant bits (bits 6 and 7) of the clock_seq_hi_and_reserved to zero and one, respectively."

The right shift by `c / 4` seems to be taking care of this, at least if JavaScript's shift operator works the way I think it does.

The `1`s are to facilitate the goofy string creation trick.

The fact that there's some discussion around the meaning of the code on HN is a bad thing, of course!

discuss

order

No comments yet.