예제 #1
0
 static RandomHelper()
 {
     using (RNGCryptoServiceProvider p = new RNGCryptoServiceProvider())
     {
         _random = new Random(p.GetHashCode());
     }
 }
예제 #2
0
        public CryptoRandom()
        {
            RNGCryptoServiceProvider p = new RNGCryptoServiceProvider();
            Random r = new Random(p.GetHashCode());

            this.RandomValue = r.NextDouble();
        }
예제 #3
0
 private static int GetCsprng()
 {
     using (var csprng = new RNGCryptoServiceProvider())
     {
         return(csprng.GetHashCode());
     }
 }
예제 #4
0
 public static double Generate()
 {
     using (var p = new RNGCryptoServiceProvider())
     {
         var r = new Random(p.GetHashCode());
         return(r.NextDouble());
     }
 }
예제 #5
0
 static NNFunctions()
 {
     using (RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider())
     {
         DateTime now = DateTime.Now;
         ZIGGURAT = new ZigguratGaussianDistribution(provider.GetHashCode() ^ now.TimeOfDay.Milliseconds ^ (int)now.TimeOfDay.TotalMilliseconds, 0, 0.01);
     }
 }
예제 #6
0
 public CryptoRandom()
 {
     using (var p = new RNGCryptoServiceProvider())
     {
         var r = new Random(p.GetHashCode());
         RandomValue = r.NextDouble();
     }
 }
예제 #7
0
 public RandomGenerator()
 {
     using (RNGCryptoServiceProvider p = new RNGCryptoServiceProvider())
     {
         Random r = new Random(p.GetHashCode());
         this.RandomValue = r.NextDouble();
     }
 }
예제 #8
0
 public trueRandom()
 {
     using (RNGCryptoServiceProvider n = new RNGCryptoServiceProvider())
     {
         Random rand = new Random(n.GetHashCode());
         randomVal = rand.NextDouble();
     }
 }
예제 #9
0
        /// <summary>
        /// Генерира квази-случаен токен
        /// </summary>
        /// <returns></returns>
        public static String randomToken()
        {
            // Додаден static модификатор од Дарко

            byte[] randomNumber = new byte[10];
            random.GetBytes(randomNumber);
            return(random.GetHashCode().ToString("X"));
        }
예제 #10
0
        // public bool IsMin1Max1 { get; set; }

        #region Constructor
        public TrueRandom() //Double Random between 0.0 and 1.0
        {
            using (RNGCryptoServiceProvider p = new RNGCryptoServiceProvider())
            {
                Random myRnd = new Random(p.GetHashCode());
                this.RandomValue = myRnd.NextDouble();
            }
        }
예제 #11
0
 public CryptoRandom()
 {
     using (RNGCryptoServiceProvider cp = new RNGCryptoServiceProvider())
     {
         Random r = new Random(cp.GetHashCode());
         this.RandValue = r.NextDouble();
     }
 }
예제 #12
0
        public void randomGenerator()
        {
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            Random rnd = new Random(rng.GetHashCode());

            do
            {
                result = rnd.Next(1000, 1500);
            } while (!isSimple(result));
        }
예제 #13
0
        ///<summary>
        /// Uses cryptopgraphy classes to make a better random number
        ///</summary>
        public static double CryptoRandomNumber()
        {
            double randValue;

            using (RNGCryptoServiceProvider rngesus = new RNGCryptoServiceProvider())
            {
                Random r = new Random(rngesus.GetHashCode());
                randValue = r.NextDouble();
            }

            return(randValue);
        }
예제 #14
0
 static CryptoRandom()
 {
     using (RNGCryptoServiceProvider rngProvider = new RNGCryptoServiceProvider())
     {
         byte[] randomBytes = new byte[4];
         rngProvider.GetBytes(randomBytes);
         int randomSeed = BitConverter.ToInt32(randomBytes);
         int hash       = rngProvider.GetHashCode();
         random = new Random(randomSeed);
         Console.WriteLine($"hash of random:{random.GetHashCode()}");
         Console.WriteLine($"seed of random:{randomSeed}");
     }
 }
예제 #15
0
        public TrueRandom(bool flag = true) //Double Random between -1.0 and 1.0
        {
            if (flag == true)
            {
                using (RNGCryptoServiceProvider p = new RNGCryptoServiceProvider())
                {
                    Random myRnd = new Random(p.GetHashCode());
                    this.RandomValue = myRnd.NextDouble() - myRnd.NextDouble();
                }
            }
            //TODO:Implement other Ranges of Randomness
            //if (flag == false)
            //{

            //}
        }
예제 #16
0
        public BigInteger NextBigInteger(int bitLength)
        {
            if (bitLength < 1)
            {
                return(BigInteger.Zero);
            }

            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            Random rnd   = new Random(rng.GetHashCode());
            int    bytes = bitLength / 8;
            int    bits  = bitLength % 8;

            byte[] bs = new byte[bytes + 1];
            rnd.NextBytes(bs);

            byte mask = (byte)(0xFF >> (8 - bits));

            bs[bs.Length - 1] &= mask;

            return(new BigInteger(bs));
        }
예제 #17
0
 public override int GetHashCode()
 {
     return(crypto.GetHashCode());
 }
예제 #18
0
        static CryptoRandom()
        {
            RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider();

            rand = new Random(rngCsp.GetHashCode());
        }