fix: Use built-in RNG (#1599)
### Summary .NET 8 supports Xoroshiro 256** off the shelf and added Shuffle. Switching to that implementation. ### Developer Notes * Removed many convenience methods that weren't used.
This commit is contained in:
parent
1769d47ba5
commit
dba3ec2db5
14 changed files with 159 additions and 699 deletions
|
|
@ -22,9 +22,7 @@ namespace Server.Accounting.Security
|
|||
{
|
||||
public static IPasswordProtection Instance = new Argon2PasswordProtection();
|
||||
|
||||
private readonly Argon2PasswordHasher m_PasswordHasher = new(
|
||||
rng: (RandomSources.SecureSource as SecureRandom)?.Generator
|
||||
);
|
||||
private readonly Argon2PasswordHasher m_PasswordHasher = new(rng: BuiltInSecureRng.Generator);
|
||||
|
||||
public string EncryptPassword(string plainPassword) =>
|
||||
m_PasswordHasher.Hash(plainPassword);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ public class ResetRng
|
|||
)]
|
||||
private static void ResetRng_OnCommand(CommandEventArgs e)
|
||||
{
|
||||
RandomSources.SetRng(new Xoshiro256PlusPlus());
|
||||
BuiltInRng.Reset();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Server.Engines.Harvest
|
|||
|
||||
if (Definition.RandomizeVeins)
|
||||
{
|
||||
m_DefaultVein = Definition.GetVeinFrom(Utility.Random(Definition.VeinWeights));
|
||||
m_DefaultVein = Definition.GetVeinFrom((uint)Utility.Random(Definition.VeinWeights));
|
||||
}
|
||||
|
||||
m_Vein = m_DefaultVein;
|
||||
|
|
|
|||
|
|
@ -135,12 +135,12 @@ namespace Server.Engines.Harvest
|
|||
|
||||
if (RandomizeVeins)
|
||||
{
|
||||
return GetVeinFrom(Utility.Random(1000u));
|
||||
return GetVeinFrom((uint)Utility.Random(1000));
|
||||
}
|
||||
|
||||
// TODO: Introduce pulling primes from a config and writing them if they don't exist to the config
|
||||
var random = new Xoshiro256PlusPlus((ulong)(x * 17 + y * 11 + map.MapID * 3));
|
||||
return GetVeinFrom(random.Next(VeinWeights));
|
||||
var seed = (ulong)(x * 17 + y * 11 + map.MapID * 3);
|
||||
return GetVeinFrom((uint)StableRandom.First(seed, VeinWeights));
|
||||
}
|
||||
|
||||
public HarvestVein GetVeinFrom(uint randomValue)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue