| Revision 176,
670 bytes
checked in by lowjoel, 5 years ago
(diff) |
|
Added the ISAAC and RNGCryptoServiceProvider CSPRNGs.
|
| Line | |
|---|
| 1 | using System; |
|---|
| 2 | using System.Collections.Generic; |
|---|
| 3 | using System.Text; |
|---|
| 4 | |
|---|
| 5 | using Eraser.Manager; |
|---|
| 6 | |
|---|
| 7 | namespace Eraser.DefaultPlugins |
|---|
| 8 | { |
|---|
| 9 | /// <summary> |
|---|
| 10 | /// ISAAC CSPRNG. |
|---|
| 11 | /// </summary> |
|---|
| 12 | public class ISAAC : PRNG |
|---|
| 13 | { |
|---|
| 14 | public override string Name |
|---|
| 15 | { |
|---|
| 16 | get { return "ISAAC CSPRNG"; } |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | public override void NextBytes(byte[] buffer) |
|---|
| 20 | { |
|---|
| 21 | //Generate 256 ints. |
|---|
| 22 | lock (isaac) |
|---|
| 23 | { |
|---|
| 24 | for (uint intsGenerated = 0; intsGenerated * sizeof(int) < buffer.Length * sizeof(byte); |
|---|
| 25 | intsGenerated += Rand.ISAAC.SIZE) |
|---|
| 26 | { |
|---|
| 27 | isaac.Isaac(); |
|---|
| 28 | isaac.rsl.CopyTo(buffer, 0); |
|---|
| 29 | } |
|---|
| 30 | } |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | private Rand.ISAAC isaac = new Rand.ISAAC(); |
|---|
| 34 | } |
|---|
| 35 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.