Michael Casadevall

Random Ways To Get To Random()

by in CodeSOD on

It's been a few days since we've done the Code Snippet Of the Day, so in lieu of Alex's normal article, here's your mid-day CodeSOD edited by Michael Casadevall ...

J.S. Bangs sends us today's snippit located deep within a Java codebase he's maintaining. The function, getRandomBits() returns a 32-byte array of random bites for security purposes. Since Java provides a Random method, this should be easy; in fact a proper implementation can be writting in five lines:


Archives