Moved getting random bytes into a separate get_random_bytes() function.