daily update on 20240506 by nitload youmu
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user