|
58 | 58 | </Attribute>
|
59 | 59 | </Attributes>
|
60 | 60 | <Docs>
|
61 |
| - <summary>Represents the abstract class from which all implementations of cryptographic random number generators derive.</summary> |
| 61 | + <summary>Provides functionality for generating random values.</summary> |
62 | 62 | <remarks>
|
63 |
| - <format type="text/markdown"><![CDATA[ |
64 |
| - |
65 |
| -## Remarks |
| 63 | + <format type="text/markdown"><![CDATA[ |
| 64 | +
|
| 65 | +## Remarks |
66 | 66 | Cryptographic random number generators create cryptographically strong random values.
|
67 | 67 |
|
| 68 | +Using the static members of this class is the preferred way to generate random values. |
| 69 | +
|
68 | 70 | To create a random number generator, call the @System.Security.Cryptography.RandomNumberGenerator.Create method. This is preferred over calling the constructor of the derived class @System.Security.Cryptography.RNGCryptoServiceProvider, which is not available on all platforms.
|
69 | 71 | ]]></format>
|
70 | 72 | </remarks>
|
@@ -113,11 +115,11 @@ To create a random number generator, call the @System.Security.Cryptography.Rand
|
113 | 115 | <Docs>
|
114 | 116 | <summary>Initializes a new instance of <see cref="T:System.Security.Cryptography.RandomNumberGenerator" />.</summary>
|
115 | 117 | <remarks>
|
116 |
| - <format type="text/markdown"><![CDATA[ |
117 |
| - |
118 |
| -## Remarks |
119 |
| - You cannot create an instance of an abstract class. Application code will create a new instance of a derived class. For an implementation of a cryptographic random number generator, use the derived class <xref:System.Security.Cryptography.RNGCryptoServiceProvider>. |
120 |
| - |
| 118 | + <format type="text/markdown"><![CDATA[ |
| 119 | +
|
| 120 | +## Remarks |
| 121 | + You cannot create an instance of an abstract class. Application code will create a new instance of a derived class. For an implementation of a cryptographic random number generator, use the derived class <xref:System.Security.Cryptography.RNGCryptoServiceProvider>. |
| 122 | +
|
121 | 123 | ]]></format>
|
122 | 124 | </remarks>
|
123 | 125 | <related type="Article" href="/dotnet/standard/security/cryptographic-services">Cryptographic Services</related>
|
@@ -303,16 +305,16 @@ To create a random number generator, call the @System.Security.Cryptography.Rand
|
303 | 305 | <Docs>
|
304 | 306 | <summary>When overridden in a derived class, releases all resources used by the current instance of the <see cref="T:System.Security.Cryptography.RandomNumberGenerator" /> class.</summary>
|
305 | 307 | <remarks>
|
306 |
| - <format type="text/markdown">< and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). |
312 |
| - |
| 308 | + <format type="text/markdown">< and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). |
| 314 | +
|
313 | 315 | > [!NOTE]
|
314 |
| -> Always call `Dispose` before you release your last reference to the <xref:System.Security.Cryptography.RandomNumberGenerator>. Otherwise, the resources it is using will not be freed until the garbage collector calls the <xref:System.Security.Cryptography.RandomNumberGenerator> object's `Finalize` method. |
315 |
| - |
| 316 | +> Always call `Dispose` before you release your last reference to the <xref:System.Security.Cryptography.RandomNumberGenerator>. Otherwise, the resources it is using will not be freed until the garbage collector calls the <xref:System.Security.Cryptography.RandomNumberGenerator> object's `Finalize` method. |
| 317 | +
|
316 | 318 | ]]></format>
|
317 | 319 | </remarks>
|
318 | 320 | </Docs>
|
@@ -361,19 +363,19 @@ To create a random number generator, call the @System.Security.Cryptography.Rand
|
361 | 363 | <see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
|
362 | 364 | <summary>When overridden in a derived class, releases the unmanaged resources used by the <see cref="T:System.Security.Cryptography.RandomNumberGenerator" /> and optionally releases the managed resources.</summary>
|
363 | 365 | <remarks>
|
364 |
| - <format type="text/markdown"><![CDATA[ |
365 |
| - |
366 |
| -## Remarks |
367 |
| - This method is called by the public `Dispose()` method and the `Finalize` method. `Dispose()` invokes the protected `Dispose(Boolean)` method with the `disposing` parameter set to `true`. `Finalize` invokes `Dispose` with `disposing` set to `false`. |
368 |
| - |
369 |
| - When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this <xref:System.Security.Cryptography.RandomNumberGenerator> references. This method invokes the `Dispose()` method of each referenced object. |
370 |
| - |
| 366 | + <format type="text/markdown"><![CDATA[ |
| 367 | +
|
| 368 | +## Remarks |
| 369 | + This method is called by the public `Dispose()` method and the `Finalize` method. `Dispose()` invokes the protected `Dispose(Boolean)` method with the `disposing` parameter set to `true`. `Finalize` invokes `Dispose` with `disposing` set to `false`. |
| 370 | +
|
| 371 | + When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this <xref:System.Security.Cryptography.RandomNumberGenerator> references. This method invokes the `Dispose()` method of each referenced object. |
| 372 | +
|
371 | 373 | ]]></format>
|
372 | 374 | </remarks>
|
373 | 375 | <block subset="none" type="overrides">
|
374 | 376 | <para>
|
375 |
| - <see langword="Dispose" /> can be called multiple times by other objects. When overriding <see langword="Dispose(Boolean)" />, be careful not to reference objects that have been previously disposed in an earlier call to <see langword="Dispose" />. For more information about how to implement <see langword="Dispose(Boolean)" />, see [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). |
376 |
| - |
| 377 | + <see langword="Dispose" /> can be called multiple times by other objects. When overriding <see langword="Dispose(Boolean)" />, be careful not to reference objects that have been previously disposed in an earlier call to <see langword="Dispose" />. For more information about how to implement <see langword="Dispose(Boolean)" />, see [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). |
| 378 | + |
377 | 379 | For more information about <see langword="Dispose" /> and <see langword="Finalize" />, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged).</para>
|
378 | 380 | </block>
|
379 | 381 | <related type="Article" href="/dotnet/standard/security/cryptographic-services">Cryptographic Services</related>
|
@@ -471,18 +473,18 @@ To create a random number generator, call the @System.Security.Cryptography.Rand
|
471 | 473 | <param name="data">The array to fill with cryptographically strong random bytes.</param>
|
472 | 474 | <summary>When overridden in a derived class, fills an array of bytes with a cryptographically strong random sequence of values.</summary>
|
473 | 475 | <remarks>
|
474 |
| - <format type="text/markdown"><![CDATA[ |
475 |
| - |
476 |
| -## Remarks |
| 476 | + <format type="text/markdown"><![CDATA[ |
| 477 | +
|
| 478 | +## Remarks |
477 | 479 | The length of the byte array determines how many random bytes are produced.
|
478 |
| - |
479 |
| -## Examples |
480 |
| - The following example creates a random sequence 100 bytes long and stores it in `random`. |
481 |
| - |
| 480 | +
|
| 481 | +## Examples |
| 482 | + The following example creates a random sequence 100 bytes long and stores it in `random`. |
| 483 | +
|
482 | 484 | :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/CPP/source.cpp" id="Snippet1":::
|
483 | 485 | :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RandomNumberGenerator/GetBytes/source.cs" id="Snippet1":::
|
484 |
| - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/VB/source.vb" id="Snippet1"::: |
485 |
| - |
| 486 | + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetBytes Example/VB/source.vb" id="Snippet1"::: |
| 487 | +
|
486 | 488 | ]]></format>
|
487 | 489 | </remarks>
|
488 | 490 | <related type="Article" href="/dotnet/standard/security/cryptographic-services">Cryptographic Services</related>
|
@@ -648,15 +650,15 @@ To create a random number generator, call the @System.Security.Cryptography.Rand
|
648 | 650 | <summary>Generates a random integer between 0 (inclusive) and a specified exclusive upper bound using a cryptographically strong random number generator.</summary>
|
649 | 651 | <returns>A random integer between 0 (inclusive) and <paramref name="toExclusive" /> (exclusive).</returns>
|
650 | 652 | <remarks>
|
651 |
| - <format type="text/markdown"><![CDATA[ |
652 |
| - |
653 |
| -## Remarks |
654 |
| - |
| 653 | + <format type="text/markdown"><![CDATA[ |
| 654 | +
|
| 655 | +## Remarks |
| 656 | +
|
655 | 657 | The upper bound is exclusive to enable passing in a length value from an array, span, or list.
|
656 | 658 | Because it is an exclusive upper bound this method can never generate <xref:System.Int32.MaxValue?displayProperty=nameWithType>.
|
657 | 659 |
|
658 | 660 | This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce.
|
659 |
| - |
| 661 | +
|
660 | 662 | ]]></format>
|
661 | 663 | </remarks>
|
662 | 664 | <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="toExclusive" /> parameter is less than or equal to 0.</exception>
|
@@ -698,17 +700,17 @@ To create a random number generator, call the @System.Security.Cryptography.Rand
|
698 | 700 | <summary>Generates a random integer between a specified inclusive lower bound and a specified exclusive upper bound using a cryptographically strong random number generator.</summary>
|
699 | 701 | <returns>A random integer between <paramref name="fromInclusive" /> (inclusive) and <paramref name="toExclusive" /> (exclusive).</returns>
|
700 | 702 | <remarks>
|
701 |
| - <format type="text/markdown"><![CDATA[ |
702 |
| - |
703 |
| -## Remarks |
704 |
| - |
| 703 | + <format type="text/markdown"><![CDATA[ |
| 704 | +
|
| 705 | +## Remarks |
| 706 | +
|
705 | 707 | The upper bound is exclusive to enable passing in a length value from an array, span, or list.
|
706 | 708 | Because it is an exclusive upper bound this method can never generate <xref:System.Int32.MaxValue?displayProperty=nameWithType>.
|
707 | 709 |
|
708 | 710 | This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce.
|
709 | 711 |
|
710 | 712 | Negative values are permitted for both `fromInclusive` and `toExclusive`.
|
711 |
| - |
| 713 | +
|
712 | 714 | ]]></format>
|
713 | 715 | </remarks>
|
714 | 716 | <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="toExclusive" /> parameter is less than or equal to the <paramref name="fromInclusive" /> parameter.</exception>
|
@@ -760,20 +762,20 @@ To create a random number generator, call the @System.Security.Cryptography.Rand
|
760 | 762 | <param name="data">The array to fill with cryptographically strong random nonzero bytes.</param>
|
761 | 763 | <summary>When overridden in a derived class, fills an array of bytes with a cryptographically strong random sequence of nonzero values.</summary>
|
762 | 764 | <remarks>
|
763 |
| - <format type="text/markdown"><![CDATA[ |
764 |
| - |
765 |
| -## Remarks |
766 |
| - The length of the byte array determines how many random bytes are produced. |
767 |
| - |
768 |
| - |
769 |
| - |
770 |
| -## Examples |
771 |
| - The following example creates a random sequence of 100 nonzero bytes and stores it in `random`. |
772 |
| - |
| 765 | + <format type="text/markdown"><![CDATA[ |
| 766 | +
|
| 767 | +## Remarks |
| 768 | + The length of the byte array determines how many random bytes are produced. |
| 769 | +
|
| 770 | +
|
| 771 | +
|
| 772 | +## Examples |
| 773 | + The following example creates a random sequence of 100 nonzero bytes and stores it in `random`. |
| 774 | +
|
773 | 775 | :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/CPP/source.cpp" id="Snippet1":::
|
774 | 776 | :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RandomNumberGenerator/GetNonZeroBytes/source.cs" id="Snippet1":::
|
775 |
| - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/VB/source.vb" id="Snippet1"::: |
776 |
| - |
| 777 | + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic RandomNumberGenerator.GetNonZeroBytes Example/VB/source.vb" id="Snippet1"::: |
| 778 | +
|
777 | 779 | ]]></format>
|
778 | 780 | </remarks>
|
779 | 781 | <related type="Article" href="/dotnet/standard/security/cryptographic-services">Cryptographic Services</related>
|
|
0 commit comments