优点和RNGCryptoServiceProvider的利弊 [英] Pros and cons of RNGCryptoServiceProvider

查看:235
本文介绍了优点和RNGCryptoServiceProvider的利弊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是使用了 System.Security.Cryptography.RNGCryptoServiceProvider 利弊VS System.Random 。我知道, RNGCryptoServiceProvider 是更随机,即少predictable黑客。任何其他的优点或缺点是什么?

What are the pros and cons of using System.Security.Cryptography.RNGCryptoServiceProvider vs System.Random. I know that RNGCryptoServiceProvider is 'more random', i.e. less predictable for hackers. Any other pros or cons?

更新:

据的响应,这里使用的利弊 RNGCryptoServiceProvider 至今:

According to the responses, here are the pros and cons of using RNGCryptoServiceProvider so far:

  • RNGCryptoServiceProvider 是一个强大的加密随机数,这意味着这将是确定加密密钥和喜欢更好。
  • RNGCryptoServiceProvider is a stronger cryptographically random number, meaning it would be better for determining encryption keys and the likes.
  • 随机速度更快,因为它是一个简单的计算;在模拟或长计算时的密码随机性并不重要使用时,这应该被使用。
  • Random is faster because it is a simpler calculation; when used in simulations or long calculations where cryptographic randomness isn't important, this should be used.

推荐答案

一个保密性强的RNG会慢一些 - 它需要更多的计算---并且将频谱白色的,但不会像适合模拟或蒙特卡罗方法,一方面是因为他们的执行的花费更多的时间,因为他们可能不重复,这是很好的测试。

A cryptographically strong RNG will be slower --- it takes more computation --- and will be spectrally white, but won't be as well suited to simulations or Monte Carlo methods, both because they do take more time, and because they may not be repeatable, which is nice for testing.

在一般情况下,你想,当你想要一个唯一的号码如UUID,或作为一个密钥进行加密,并确定PRNG的速度和模拟用密码学的PRNG。

In general, you want to use a cryptographic PRNG when you want a unique number like a UUID, or as a key for encryption, and a deterministic PRNG for speed and in simulation.

这篇关于优点和RNGCryptoServiceProvider的利弊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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