DEV Community

Cover image for Random numbers in CSS? Really? πŸŽ²πŸ€”

Random numbers in CSS? Really? πŸŽ²πŸ€”

Pascal Thormeier on April 14, 2021

I just read this awesome post by inhuofficial about a random password generator written in pure CSS. It follows a similar approach as some other pu...
Collapse
 
togakangaroo profile image
George Mauer

Electricity either flows (1) or it doesn't (0)

If we're breaking things down then this isn't true either, right? Some electrons are always being passed around and electricity is already following. It is neither constant not discrete and certainly not digital. In fact nothing about zeros and ones has anything to do with electricity at all but with information theory which posits exalt that reliable, digital systems can be created from unreliable analog ones. Interestingly enough, if you could go the other direction, you probably could get true random numbers but at that point Claude Shannon decided he had done enough and wanted to do juggling for a while.

Anyways, that's been your pedantic aside 😁

Collapse
 
thormeier profile image
Pascal Thormeier

You're technically right, yes. Usually it's either a lot of electrons (as in 6.24 * 10^18) flowing, or next to none. That's usually enough of a difference to be more or less reliable in a sense. Of course, quantum weirdness plays in as well. A CSS-only-RNG needs a user to give an input to settle down on a single number, much like a particle in a superposition needs an observer. πŸ˜„

Collapse
 
grahamthedev profile image
GrahamTheDev • Edited

Thanks for the shout out....even if you did β€œsteal” my next article idea (and annoyingly write it better than I would have!) 🀣🀣🀣

Collapse
 
thormeier profile image
Pascal Thormeier

Aw, no way, really? πŸ˜… Your article got me thinking about the topic, I found it really inspiring!

Collapse
 
grahamthedev profile image
GrahamTheDev

Only kidding, loved the article. But i was having the same thoughts!

Followed! ❀️

Thread Thread
 
thormeier profile image
Pascal Thormeier

Thank you so much! Great minds think alike, they say :) Followed back!

Thread Thread
 
grahamthedev profile image
GrahamTheDev

The problem with that sentence is the second part β€œgreat minds think alike...but fools seldom differ”....I will give us both the benefit of the doubt on this one though 😜🀣🀣🀣

Thread Thread
 
thormeier profile image
Pascal Thormeier

Yep, I tend to ignore the second part usuallyπŸ˜†

Collapse
 
afif profile image
Temani Afif

We will have it for real one day: github.com/w3c/csswg-drafts/issues...

Collapse
 
thormeier profile image
Pascal Thormeier

Woho, looking forward to that! :D I wonder what kind of designs people come up with once this hits the browsers.

Collapse
 
gadreash profile image
gadreash

This was one of those articles which is so well written that despite my knee-jerk reaction being "too technical, abort", I kept reading till the end!!
You definitely have a flair for writing complex stuff in an easy to digest manner, keep it up!

Collapse
 
thormeier profile image
Pascal Thormeier

Thank you so much, that means a lot to me! I'll try my best to further create such content :D

Collapse
 
filatovv profile image
Yuri Filatov

Thanks for the great article!

Collapse
 
thormeier profile image
Pascal Thormeier

Glad you liked it! :)

Collapse
 
arvindpdmn profile image
Arvind Padmanabhan

Also check out the use of prime numbers in CSS: devopedia.org/cicada-principle

Collapse
 
thormeier profile image
Pascal Thormeier

That's so awesome! Thank you for sharing this, I need to dig deeper into that πŸ˜€