lundi 7 janvier 2019

Do I have to reopen /dev/urandom every read?

I have a server running in a forever loop. Every once in a while the server has to execute the hashing of a password (more specifically, every time a user sign up to my service). The hashing algorithm needs a salt, 16 random bytes, which I read from /dev/urandom, as recommended by many.

So I thought: why not call fopen("/dev/urandom", "rb") only once at the start of the server and then call fread as I need?

The examples I found in the web usually shows fread immediately preceded by fopen. But isn't that expensive?




Aucun commentaire:

Enregistrer un commentaire