3 ms·
Most programming languages do not use secure random number generators. As you suggested it is not always wise to use UUIDs for API keys if you are not sure abou
by justusw 10y ago
Most programming languages do not use secure random number generators. As you suggested it is not always wise to use UUIDs for API keys if you are not sure about the nature of the PRNG.
Python for example uses os.urandom for random UUID generation (uuid4), as can be seen in the source: https://github.com/python/cpython/blob/3.5/Lib/uuid.py#L603 https://github.com/python/cpython/blob/3.5/Lib/uuid.py#L603
The standard library guarantees that os.urandom is "[...] suitable for cryptographic use." (https://docs.python.org/3.5/library/os.html#os.urandom https://docs.python.org/3.5/library/os.html#os.urandom)
I'm not sure about other languages, so it might always be a good idea to look it up in the source code.
- nitrogen 10y agoIn Ruby you should use the SecureRandom module, but even that has had issues in the past. http://ruby-doc.org/stdlib-2.3.1/libdoc/securerandom/rdoc/index.html http://ruby-doc.org/stdlib-2.3.1/libdoc/securerandom/rdoc/in... https://news.ycombinator.com/item?id=11624890 https://news.ycombinator.com/item?id=11624890
- MichaelGG 10y agoSeems like it still has issues? The bug is still open. Embarrassing but entertaining.