Fastest implementation of a true random number generator in C#

前端 未结 8 1209
隐瞒了意图╮
隐瞒了意图╮ 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条回答
  •  萌比男神i
    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.

提交回复
热议问题