SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public Task<byte[]> GetEntropy1(int length)
  2. {
  3.     RNGCryptoServiceProvider entropyGen = new RNGCryptoServiceProvider();
  4.     byte[] entropyBuffer = new byte[2048];
  5.  
  6.     try
  7.     {
  8.         semaphore.Wait();
  9.  
  10.         Task t = Task.Run(() =>
  11.         {
  12.             /* gather entropy from sensors */
  13.         });
  14.  
  15.         if (!t.Wait(5000))
  16.         {
  17.             entropyGen.GetBytes(entropyBuffer);
  18.         }
  19.         return entropyBuffer;
  20.     }
  21.     catch (Exception)
  22.     {
  23.         return entropyBuffer;
  24.     }
  25.     finally
  26.     {
  27.         this.semaphore.Release();
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top