IRandomGenerator.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng
  5. {
  6. /// <remarks>Generic interface for objects generating random bytes.</remarks>
  7. public interface IRandomGenerator
  8. {
  9. /// <summary>Add more seed material to the generator.</summary>
  10. /// <param name="seed">A byte array to be mixed into the generator's state.</param>
  11. void AddSeedMaterial(byte[] seed);
  12. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  13. void AddSeedMaterial(ReadOnlySpan<byte> seed);
  14. #endif
  15. /// <summary>Add more seed material to the generator.</summary>
  16. /// <param name="seed">A long value to be mixed into the generator's state.</param>
  17. void AddSeedMaterial(long seed);
  18. /// <summary>Fill byte array with random values.</summary>
  19. /// <param name="bytes">Array to be filled.</param>
  20. void NextBytes(byte[] bytes);
  21. /// <summary>Fill byte array with random values.</summary>
  22. /// <param name="bytes">Array to receive bytes.</param>
  23. /// <param name="start">Index to start filling at.</param>
  24. /// <param name="len">Length of segment to fill.</param>
  25. void NextBytes(byte[] bytes, int start, int len);
  26. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  27. void NextBytes(Span<byte> bytes);
  28. #endif
  29. }
  30. }
  31. #pragma warning restore
  32. #endif