Fix for pull request #146

This commit is contained in:
sta 2015-08-04 15:50:36 +09:00
parent 82f089730e
commit 586a6202a2
2 changed files with 3 additions and 4 deletions

View File

@ -115,6 +115,7 @@ namespace WebSocketSharp
#region Internal Fields #region Internal Fields
internal const int FragmentLength = 1016; // Max value is Int32.MaxValue - 14. internal const int FragmentLength = 1016; // Max value is Int32.MaxValue - 14.
internal static readonly RandomNumberGenerator RandomNumber = new RNGCryptoServiceProvider ();
#endregion #endregion
@ -1627,8 +1628,7 @@ namespace WebSocketSharp
internal static string CreateBase64Key () internal static string CreateBase64Key ()
{ {
var src = new byte[16]; var src = new byte[16];
var rand = new Random (); RandomNumber.GetBytes (src);
rand.NextBytes (src);
return Convert.ToBase64String (src); return Convert.ToBase64String (src);
} }

View File

@ -277,8 +277,7 @@ namespace WebSocketSharp
private static byte[] createMaskingKey () private static byte[] createMaskingKey ()
{ {
var key = new byte[4]; var key = new byte[4];
var rand = new Random (); WebSocket.RandomNumber.GetBytes (key);
rand.NextBytes (key);
return key; return key;
} }