Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Task<byte[]> GetEntropy1(int length)
- {
- RNGCryptoServiceProvider entropyGen = new RNGCryptoServiceProvider();
- byte[] entropyBuffer = new byte[2048];
- try
- {
- semaphore.Wait();
- Task t = Task.Run(() =>
- {
- /* gather entropy from sensors */
- });
- if (!t.Wait(5000))
- {
- entropyGen.GetBytes(entropyBuffer);
- }
- return entropyBuffer;
- }
- catch (Exception)
- {
- return entropyBuffer;
- }
- finally
- {
- this.semaphore.Release();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement