I was using the following code to generate sequence of pseudo-random numbers that was used for cryptographic purposes, but then I read somewhere that it may not be very secure.
Don't "roll your own" cryptography. Use a certified library instead.
For speed, try using a library that can run on the GPU, which has far more computing power.