为什么要使用C#类System.Random可言,而不是System.Security.Cryptography.RandomNumberGenerator? [英] Why use the C# class System.Random at all instead of System.Security.Cryptography.RandomNumberGenerator?

查看:172
本文介绍了为什么要使用C#类System.Random可言,而不是System.Security.Cryptography.RandomNumberGenerator?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么会有人用标准的随机数发生器从 System.Random 在所有的,而不是始终使用加密安全随机数生成器从<一个href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.randomnumbergenerator.aspx">System.Security.Cryptography.RandomNumberGenerator (或它的子类,因为RandomNumberGenerator是抽象的)?

Why would anybody use the "standard" random number generator from System.Random at all instead of always using the cryptographically secure random number generator from System.Security.Cryptography.RandomNumberGenerator (or its subclasses because RandomNumberGenerator is abstract)?

内特 - 劳森告诉我们,在他的谷歌技术讲座presentation加密反击在分13 :11不使用标准的随机数生成器在Python,Java和C#,并转而使用加密安全版

Nate Lawson tells us in his Google Tech Talk presentation "Crypto Strikes Back" at minute 13:11 not to use the "standard" random number generators from Python, Java and C# and to instead use the cryptographically secure version.

我知道这两个版本的随机数生成器之间的差异(见<一href="http://stackoverflow.com/questions/101337/what-is-the-difference-between-a-randomly-generated-number-and-secure-randomly-ge">question 101337 )。

I know the difference between the two versions of random number generators (see question 101337).

但是,什么理由是存在于并不总是使用安全随机数生成?为什么要使用System.Random呢?性能吧?

But what rationale is there to not always use the secure random number generator? Why use System.Random at all? Performance perhaps?

推荐答案

速度和意图。如果你产生一个随机数,并没有出于安全需要,为什么要使用一个缓慢的加密功能?你不需要安全,为什么让别人认为一些可用于一些安全时,它会不会?

Speed and intent. If you're generating a random number and have no need for security, why use a slow crypto function? You don't need security, so why make someone else think that the number may be used for something secure when it won't be?

这篇关于为什么要使用C#类System.Random可言,而不是System.Security.Cryptography.RandomNumberGenerator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆