真随机c#生成器 [英] Real random c# generator

查看:140
本文介绍了真随机c#生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Random ran = new Random();
        byte tmp;            
            tmp = (byte)ran.Next(10);

此代码有替代方法吗?似乎没有完全随机的行为...

Is there an alternative to this code? It seems to have not fully random behavior...

推荐答案

这是因为随机只是伪随机的。如果您想要加密安全的随机数字,您需要使用类 System.Security。 Cryptography.RNGCryptoServiceProvider

That is because Random is only pseudo-random. If you want cryptographically secure random numbers you need to use a class like System.Security.Cryptography.RNGCryptoServiceProvider

这篇关于真随机c#生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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