daily update on 20240506 by nitload youmu

This commit is contained in:
YoumuLiu
2024-05-07 05:12:28 +08:00
parent 66efce19fc
commit fc19ab3298
83 changed files with 1161 additions and 741 deletions
+32 -2
View File
@@ -29,10 +29,15 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Controlling;
using StgSharp.Math.HighPrecession;
using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics.Arm;
using System.Security.Cryptography;
using System.Text;
namespace StgSharp.Math
@@ -77,14 +82,39 @@ namespace StgSharp.Math
return result;
}
private static byte[] randomSeed;
/// <summary>
///
/// </summary>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Random()
public static T Random<T>() where T : struct, IConvertible
#if NET8_0_OR_GREATER
,INumber
#endif
{
throw new NotImplementedException();
if (randomSeed==null)
{
randomSeed = new byte[64];
var originSeed =
$"{(Assembly.GetEntryAssembly()==null? Assembly.GetAssembly(typeof(StgSharp))!:
Assembly.GetEntryAssembly())}" +
$"{DateTime.UtcNow.ToString("o")}";
using (SHA256 sha = SHA256.Create())
{
randomSeed = sha.ComputeHash(Encoding.UTF8.GetBytes(originSeed));
}
}
using (SHA256 sha = SHA256.Create())
{
randomSeed = sha.ComputeHash(randomSeed);
}
fixed (byte* bptr = randomSeed)
{
return *(T*)bptr;
}
}
/// <summary>