Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Use RNG.Fill in SocketsHttpHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
bartonjs committed Feb 14, 2018
1 parent c3a92a2 commit c88729d
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ internal partial class AuthenticationHelper
// 48='0', 65='A', 97='a'
private static int[] s_alphaNumChooser = new int[] { 48, 65, 97 };

// Define a random number generator for cnonce
private static RandomNumberGenerator s_rng = RandomNumberGenerator.Create();

public async static Task<bool> TrySetDigestAuthToken(HttpRequestMessage request, ICredentials credentials, DigestResponse digestResponse, string authHeader)
{
NetworkCredential credential = credentials.GetCredential(request.RequestUri, Digest);
Expand Down Expand Up @@ -218,7 +215,7 @@ private static string GetRandomAlphaNumericString()
{
const int Length = 16;
Span<byte> randomNumbers = stackalloc byte[Length * 2];
s_rng.GetBytes(randomNumbers);
RandomNumberGenerator.Fill(randomNumbers);

StringBuilder sb = StringBuilderCache.Acquire(Length);
for (int i = 0; i < randomNumbers.Length;)
Expand Down

0 comments on commit c88729d

Please sign in to comment.