From d61d3c201a572c70bf05cd1984e75b01ebc50ddd Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 9 Jul 2016 13:12:46 -0400 Subject: [PATCH] singleton Random() --- src/App/Services/CryptoService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/App/Services/CryptoService.cs b/src/App/Services/CryptoService.cs index b9207811e..b605d8ca9 100644 --- a/src/App/Services/CryptoService.cs +++ b/src/App/Services/CryptoService.cs @@ -20,6 +20,7 @@ namespace Bit.App.Services private const int KeySize = 256; private const int Iterations = 5000; + private readonly Random _random = new Random(); private readonly PaddedBufferedBlockCipher _cipher; private readonly ISecureStorageService _secureStorage; private KeyParameter _keyParameter; @@ -184,9 +185,8 @@ namespace Bit.App.Services private byte[] GenerateRandomInitializationVector() { - var rand = new Random(); var iv = new byte[InitializationVectorSize]; - rand.NextBytes(iv); + _random.NextBytes(iv); return iv; } }