rngcryptoserviceprovider

How can the RNGCryptoServiceProvider be used to generate Bridge hands?

倖福魔咒の 提交于 2020-01-02 05:43:08
问题 The game of Bridge is played with 52 different playing cards that are randomly distributed among four players, each player ending up with thirteen cards: a so called "deal". Roughly a little less than 2^96 Bridge deals are possible. In this document the requirements for a program that generates random deals are described as follows: The software should be able to generate every possible bridge deal, since that is also possible with manual dealing. The software should generate every deal with

How “good” is this method for generating random numbers?

空扰寡人 提交于 2019-12-04 16:01:19
问题 I was searching on google for RNGCryptoServiceProvider with examples on how to limit the range between Max and Min, and still get an even distribution. Before I used modulo operator, but sometimes it I get strange values (above Max)... Anyways this code (credit to unknown) seeds Random with a new seed from RNGCCryptoServiceProvider, everytime the method is called. What do you guys think? public static int GetRandom(int min, int max) { byte[] b = new byte[sizeof(int)]; new System.Security

How “good” is this method for generating random numbers?

感情迁移 提交于 2019-12-03 09:09:57
I was searching on google for RNGCryptoServiceProvider with examples on how to limit the range between Max and Min, and still get an even distribution. Before I used modulo operator, but sometimes it I get strange values (above Max)... Anyways this code (credit to unknown) seeds Random with a new seed from RNGCCryptoServiceProvider, everytime the method is called. What do you guys think? public static int GetRandom(int min, int max) { byte[] b = new byte[sizeof(int)]; new System.Security.Cryptography.RNGCryptoServiceProvider().GetBytes(b); int i = BitConverter.ToInt32(b, 0); Random r = new