mscorlib(4.0.0.0) API with additions
RandomNumberGenerator.cs
2 
4 {
6  [ComVisible(true)]
7  public abstract class RandomNumberGenerator : IDisposable
8  {
11  public static RandomNumberGenerator Create()
12  {
13  return Create("System.Security.Cryptography.RandomNumberGenerator");
14  }
15 
19  public static RandomNumberGenerator Create(string rngName)
20  {
22  }
23 
25  public void Dispose()
26  {
27  Dispose(disposing: true);
28  GC.SuppressFinalize(this);
29  }
30 
34  protected virtual void Dispose(bool disposing)
35  {
36  }
37 
40  public abstract void GetBytes(byte[] data);
41 
52  public virtual void GetBytes(byte[] data, int offset, int count)
53  {
54  if (data == null)
55  {
56  throw new ArgumentNullException("data");
57  }
58  if (offset < 0)
59  {
60  throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
61  }
62  if (count < 0)
63  {
64  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
65  }
66  if (offset + count > data.Length)
67  {
68  throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
69  }
70  if (count > 0)
71  {
72  byte[] array = new byte[count];
73  GetBytes(array);
74  Array.Copy(array, 0, data, offset, count);
75  }
76  }
77 
80  public virtual void GetNonZeroBytes(byte[] data)
81  {
82  throw new NotImplementedException();
83  }
84  }
85 }
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static void SuppressFinalize(object obj)
Requests that the common language runtime not call the finalizer for the specified object.
Definition: GC.cs:308
static RandomNumberGenerator Create(string rngName)
When overridden in a derived class, creates an instance of the specified implementation of a cryptogr...
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
Definition: IDisposable.cs:8
static object CreateFromName(string name, params object[] args)
Creates a new instance of the specified cryptographic object with the specified arguments.
Definition: __Canon.cs:3
virtual void GetNonZeroBytes(byte[] data)
When overridden in a derived class, fills an array of bytes with a cryptographically strong random se...
The exception that is thrown when the value of an argument is outside the allowable range of values a...
static RandomNumberGenerator Create()
When overridden in a derived class, creates an instance of the default implementation of a cryptograp...
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
Accesses the cryptography configuration information.
Definition: CryptoConfig.cs:17
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
Controls the system garbage collector, a service that automatically reclaims unused memory.
Definition: GC.cs:11
The exception that is thrown when one of the arguments provided to a method is not valid.
Represents the abstract class from which all implementations of cryptographic random number generator...
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Definition: Array.cs:1275
abstract void GetBytes(byte[] data)
When overridden in a derived class, fills an array of bytes with a cryptographically strong random se...
virtual void Dispose(bool disposing)
When overridden in a derived class, releases the unmanaged resources used by the T:System....
virtual void GetBytes(byte[] data, int offset, int count)
Fills the specified byte array with a cryptographically strong random sequence of values.
The exception that is thrown when a requested method or operation is not implemented.
void Dispose()
When overridden in a derived class, releases all resources used by the current instance of the T:Syst...