Refine random generator handling

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
Syrone Wong
2016-10-20 08:15:47 +08:00
parent 4b99a5c210
commit ce26bc15a9
+4 -4
View File
@@ -237,10 +237,10 @@ namespace Shadowsocks.Encryption
protected static void randBytes(byte[] buf, int length)
{
byte[] temp = new byte[length];
RNGCryptoServiceProvider rngServiceProvider = new RNGCryptoServiceProvider();
rngServiceProvider.GetBytes(temp);
temp.CopyTo(buf, 0);
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
{
rng.GetBytes(buf, 0, length);
}
}
public override void Encrypt(byte[] buf, int length, byte[] outbuf, out int outlength)