Esempio n. 1
0
        public static Byte[] GetRandomBytes(int Count)
        {
            var Buffer = new Byte[Count];

            SodiumRNGLibrary.randombytes_buf(Buffer, Count);

            return(Buffer);
        }
Esempio n. 2
0
        public static uint GetUniformUpperBoundRandomNumber(uint upperBound)
        {
            if (upperBound < 2)
            {
                throw new ArgumentException("Error: Upper Bound should not be less than 2");
            }

            var randomNumber = SodiumRNGLibrary.randombytes_uniform(upperBound);

            return(randomNumber);
        }
Esempio n. 3
0
        public static Byte[] GetSeededRandomBytes(long Count, Byte[] Seed)
        {
            var  Buffer  = new Byte[Count];
            long Checker = 274877766207;

            if (Seed.Length == GetSeedBytesValue())
            {
                if (Count <= Checker)
                {
                    SodiumRNGLibrary.randombytes_buf_deterministic(Buffer, Count, Seed);
                }
                else
                {
                    throw new ArgumentException("Error: Count size cannot bigger than " + Checker.ToString());
                }
            }
            else
            {
                throw new ArgumentException("Error: Seed length is not equals to " + (GetSeedBytesValue()).ToString());
            }
            return(Buffer);
        }
Esempio n. 4
0
 public static int GetSeedBytesValue()
 {
     return(SodiumRNGLibrary.randombytes_seedbytes());
 }
Esempio n. 5
0
        public static uint GetRandomNumber()
        {
            var randomNumber = SodiumRNGLibrary.randombytes_random();

            return(randomNumber);
        }