This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CPUTotalPC | |
{ | |
private static PerformanceCounter _CPUsage; | |
public static double CPULoad | |
{ | |
get | |
{ | |
if (_CPUsage == null) | |
{ | |
try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class GArray<T> | |
{ | |
private readonly int _capacity = 4096; | |
private int _count; | |
private int _position; | |
private T[] Thing; | |
public GArray() | |
{ | |
_capacity = 4096; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CryptoGetBytes | |
{ | |
private readonly SHA512Managed _Hasher = new SHA512Managed(); | |
private readonly SeedBytes _SeedBytes; | |
private int _AvailableCacheBytes; | |
private byte[] _Buffer; | |
private byte[] _Cache; | |
private int _Ptr; | |
public CryptoGetBytes() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public BigInteger Remainder => Numerator % Denominator; | |
private static ulong HashHold; | |
private static string DecimalString = "0"; | |
private static readonly FNV1a64 _Hasher = new FNV1a64(); | |
public static int DisplayPrecision = 100; | |
public string AsDecimal(bool rounding = false, int toDigits = 100) | |
{ | |
var lh = _Hasher.Hash64(Numerator.ToByteArray()) ^ _Hasher.Hash64(Denominator.ToByteArray()); | |
if (HashHold == lh) return DecimalString; | |
if (DisplayPrecision < 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CryptoRandomNumberGenerator<T> where T : struct | |
{ | |
private static BigRational _maxValue; | |
private readonly byte[] _buffer; | |
private readonly BigRational _mult; | |
private readonly CryptoGetBytes _ncsp; | |
private int _availableCacheEntries; | |
private BigRational[] _cache; | |
private int _cacheptr; | |
private int _cacheSize = 1000000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class BigIntegerHelper | |
{ | |
private static readonly BigInteger Ten = new BigInteger(10); | |
public static BigInteger ToBigInteger(this ulong ul) | |
{ | |
return new BigInteger(ul); | |
} | |
public static BigInteger ToBigInteger(this long ul) | |
{ | |
return new BigInteger((ulong) ul); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class LimitedStack<T> : IEnumerable<T> | |
{ | |
private T[] _array; | |
public LimitedStack(int maxsize) | |
{ | |
if (maxsize == 0) | |
throw new Exception("The MaxSize argument must be greater than 0"); | |
MaxSize = maxsize; | |
_array = new T[MaxSize]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Randomness extractor for Small and Large seed buffers based on CPU noise/jitter. | |
/// </summary> | |
public class CryptoSeedBytes | |
{ | |
private readonly object _lock = new object(); | |
public CryptoSeedBytes() | |
{ | |
TSCSupport = Tsc_supported(); | |
AdjustAdditionLoopLimits(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// https://en.wikipedia.org/wiki/Zobrist_hashing | |
/// Faster then GetHashCode, 6 collisions / 435,000 English words, ~20 Collisions / 400,000 | |
/// random byte patterns. | |
/// </summary> | |
public class ZOB64 : HashAlgorithm | |
{ | |
private ulong[] _table; | |
private ulong hash; | |
private uint hash32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ZOB64 : HashAlgorithm | |
{ | |
private ulong[] _table; | |
private ulong hash; | |
private uint hash32; | |
private readonly ulong starthash = 0x391615744853B307; | |
private ZOB32State zhs; | |
public ZOB64() | |
{ | |
hash = starthash; |