Moving to RandomNumberGenerator as CryptRandom is not supported in Mono

This commit is contained in:
harshgMSFT 2014-07-23 16:25:17 -07:00
parent 47d227cbf2
commit b1912d799c
1 changed files with 3 additions and 1 deletions

View File

@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using Microsoft.AspNet.Security.DataProtection;
@ -17,6 +18,7 @@ namespace Microsoft.AspNet.Mvc
[DebuggerDisplay("{DebuggerString}")]
internal sealed class BinaryBlob : IEquatable<BinaryBlob>
{
private static readonly RandomNumberGenerator _randomNumberGenerator = RandomNumberGenerator.Create();
private readonly byte[] _data;
// Generates a new token using a specified bit length.
@ -93,7 +95,7 @@ namespace Microsoft.AspNet.Mvc
private static byte[] GenerateNewToken(int bitLength)
{
var data = new byte[bitLength / 8];
CryptRand.FillBuffer(new ArraySegment<byte>(data));
_randomNumberGenerator.GetBytes(data);
return data;
}