Fastest implementation of a true random number generator in C#

前端 未结 8 1179
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 23:23

I was reading about Random.Next() that for \"cryptographically secure random number suitable for creating a random password\" MSDN suggests RNGCryptoServiceProvider Class

相关标签:
8条回答
  • 2020-12-09 00:00

    Another point that hasn't been brought up:

    PRNG will produce predictable results given the same initial seed value. CSPRNG will not - it has no seed value. This makes PRNGs (to some degree) suitable for use in cypher stream algorithms. Two computers given the same initialization vectors (used as seed values to one or more PRNGs) could effectively communicate with each other in private using the XORed result of the plain text bytes and the output of the seeded PNG(s) used.

    I'm not claiming that such an implementation would be necessarily be cryptographically secure of course; only that such an implementation would require the predictability of a PRNG that CSPRNG does not offer.

    0 讨论(0)
  • 2020-12-09 00:02

    The only known way to get truly random numbers in hardware is slow; if you try to speed it up your hair turns white, falls out in clumps, and the NRC sends robots in to clean up your server room.

    I'm with Mehrdad on this one: don't try to roll your own.

    0 讨论(0)
提交回复
热议问题