Fast pseudorandom number generator for cryptography in C

前端 未结 4 2864
傲寒
傲寒 2021-02-20 16:35

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.

4条回答
  •  借酒劲吻你
    2021-02-20 16:42

    Look at (or use) the random number generator in the OpenSSL library.

    The hard part with any secure random number generator is the seeding. If you are on Windows, consider using rand_s(). On Linux look at /dev/urand.

    Some seeding methods suffer from not being very random soon after a reboot. You can make a file with random bytes. Use the file and the OS method for seeding. Periodically use your random number generator to write a new file.

提交回复
热议问题