Entropy in /dev/random vs used RAM

This time I didn’t really know what to let my computer do. So I opted to let it calculate the correlation between used RAM and entropy pool level in /dev/random. At first I thought that there would be no correlation whatsoever since I thought that the two variables were almost totally unrelated. It turns out I was wrong but that makes sense now.

In order to fulfil this task, I decided to make a measurement of both values every 5 seconds, during a few hours where I’d use the computer and some minutes where I wasn’t.

The bash and R scripts that I used can be found on my github repository.

And the results there.

Here’s a plot of both the entropy and used RAM in function of time.

entropy-ram  Like one could guess from the plot, the correlation is negative. For the whole data (that goes outside the range of the graph), the correlation turns out to be worth about -0.20.

One explanation for such (surprising to me) result is that the more used RAM implies more programs running and programs seem to use /dev/random (though I wonder why they don’t use /dev/urandom instead since the latter is “ok” for more than 99% of purposes including random password generators).

One day later I decided to rerun the experiment, this time well after having rebooted my machine so that I don’t start with a low used RAM (and high entropy pool level). To my surprise the results were quite different: the correlation is worth only -0.02. A graph of the results an be found below:

entropyvsRAM-secondtry

It looks like long period of inactivity left both my used RAM and entropy pool level oscillating around a certain value, and as soon as activity went up in my computer both values started to be more chaotic.

Invoke a command to generate a random password of length n

Here’s one way to generate a -good- random password of length n invoking a simple command in the terminal, like so for instance: psswd 30 , where 30 stands for a 30 characters long password.

In order to do so, you need to edit ~/.bashrc or ~/.zshrc depending whether your shell is bash or zsh, and append psswd() { LC_ALL=C tr -dc ‘a-zA-Z0-9-!”@/#$%^&*()_+~’ < /dev/urandom | head -c “$1”;echo ;} to the file, then save it and restart the terminal if you had any opened. Now typing psswd n where n stands for the password length will generate a random password that may contain alphanumerical characters as well as the special characters displayed between the 2 ‘ signs. You can of course modify the characters used to generate the passwords and the function “psswd()” to any of your like.

To finish this blog entry, here’s an example of a 100 characters long password generated by the above command: WTx@X#!O$q!b!IDu+M7gvMVTv-^QK8O-(Y”NMO&%)P1Z4)h2K03uwf(Yc^~h76yi2&CaFE$$R3L&c$XKvnBsojJ6MBgW/S$q-_&o.

Have fun.