BraintreeEncryption.Library.BouncyCastle.Crypto.Prng.ThreadedSeedGenerator.SeedGenerator.GenerateSeed C# (CSharp) Méthode

GenerateSeed() public méthode

public GenerateSeed ( int numBytes, bool fast ) : byte[]
numBytes int
fast bool
Résultat byte[]
            public byte[] GenerateSeed(
				int		numBytes,
				bool	fast)
            {
                this.counter = 0;
                this.stop = false;

                byte[] result = new byte[numBytes];
                int last = 0;
                int end = fast ? numBytes : numBytes * 8;

                ThreadPool.QueueUserWorkItem(new WaitCallback(Run));

                for (int i = 0; i < end; i++)
                {
                    while (this.counter == last)
                    {
                        try
                        {
                            Thread.Sleep(1);
                        }
                        catch (Exception)
                        {
                            // ignore
                        }
                    }

                    last = this.counter;

                    if (fast)
                    {
                        result[i] = (byte) last;
                    }
                    else
                    {
                        int bytepos = i / 8;
                        result[bytepos] = (byte) ((result[bytepos] << 1) | (last & 1));
                    }
                }

                this.stop = true;

                return result;
            }
ThreadedSeedGenerator.SeedGenerator