diff --git a/BepInEx.Bootstrap/BepInEx.Bootstrap.csproj b/BepInEx.Bootstrap/BepInEx.Bootstrap.csproj index 856be7b..f6b4bfc 100644 --- a/BepInEx.Bootstrap/BepInEx.Bootstrap.csproj +++ b/BepInEx.Bootstrap/BepInEx.Bootstrap.csproj @@ -28,6 +28,7 @@ + diff --git a/BepInEx.Bootstrap/RngEntrypoint.cs b/BepInEx.Bootstrap/RngEntrypoint.cs new file mode 100644 index 0000000..e45aade --- /dev/null +++ b/BepInEx.Bootstrap/RngEntrypoint.cs @@ -0,0 +1,34 @@ +using System.Runtime.InteropServices; +using System.Security.Cryptography; + +namespace BepInEx.Bootstrap +{ + [ComVisible(true)] + public class RngEntrypoint : RandomNumberGenerator + { + private RNGCryptoServiceProvider InternalProvider { get; } + + static RngEntrypoint() + { + Entrypoint.Init(); + } + + public RngEntrypoint() + => InternalProvider = new RNGCryptoServiceProvider(); + + public RngEntrypoint(string str) + => InternalProvider = new RNGCryptoServiceProvider(str); + + public RngEntrypoint(byte[] rgb) + => InternalProvider = new RNGCryptoServiceProvider(rgb); + + public RngEntrypoint(CspParameters cspParams) + => InternalProvider = new RNGCryptoServiceProvider(cspParams); + + public override void GetBytes(byte[] data) + => InternalProvider.GetBytes(data); + + public override void GetNonZeroBytes(byte[] data) + => InternalProvider.GetNonZeroBytes(data); + } +} \ No newline at end of file