using System;
using System.Collections.Generic;
using System.Text;

namespace Helper
{
    public static class MathEx
    {
        public static int RNGRandom(int max)
        {
            int rnd = int.MinValue;
            decimal _base = (decimal)long.MaxValue;
            byte[] rndSeries = new byte[8];
            System.Security.Cryptography.RNGCryptoServiceProvider rng
                 = new System.Security.Cryptography.RNGCryptoServiceProvider();
            rng.GetBytes(rndSeries);
            rnd = (int)(Math.Abs(BitConverter.ToInt64(rndSeries, 0)) / _base * (max ));
            return rnd;
        }
    }
}
