INNER CODE UNIT · C#
CACHE_THRESHOLD
sdrapkin/SecurityDriven.Inferno · CryptoRandom.cs:16
const int CACHE_THRESHOLD = 64; // 64 yields ~ 1/3 perf ratio between cache hit and BCrypt call to repopulate the cache
const int BYTE_CACHE_SIZE = 4096; // 4k buffer seems to work best (empirical experimentation). Buffer must be larger than CACHE_THRESHOLD.
readonly byte[] _byteCache = new byte[BYTE_CACHE_SIZE];
int _byteCachePosition = BYTE_CACHE_SIZE;
static CryptoRandom()
{
SanityCheck();
}// static ctor
public CryptoRandom() : base(Seed: 0)
{
// Minimize the wasted time of calling default System.Random base ctor.
// We can't avoid calling at least some base ctor, ie. 2~3 milliseconds are wasted anyway.
// That's the price of inheriting from System.Random (doesn't implement an interface).
}// ctor
static void SanityCheck()