生成真随机数

//获取len位真随机数字(真随机数)
        public static string GetRealRandomNum(int len)
        {
            var sb = new StringBuilder();
            byte[] data = new byte[len];
            using (var provider = new RNGCryptoServiceProvider())
            {
                provider.GetBytes(data);
                foreach (byte item in data)
                {
                    string temp = (item % 10).ToString();
                    sb.Append(temp);
                }
            }
            return sb.ToString();
        }

 

posted @ 2017-07-07 10:57  唔愛吃蘋果  阅读(134)  评论(0编辑  收藏  举报