Skip to content

Instantly share code, notes, and snippets.

@mjs3339
mjs3339 / ArrayMixer.cs
Created July 27, 2020 04:39
Uses Sha3 to Shuffle Primitive Arrays
using System;
public class ArrayMixer
{
private readonly SHA3ModInt _alg;
private readonly int _moveSize;
public ArrayMixer(int hashSize = 256)
{
_alg = new SHA3ModInt(hashSize);
_moveSize = _alg.ComputeHash(2.GetBytes()).Length;
}
@mjs3339
mjs3339 / NativeWin32.cs
Created July 27, 2020 04:30
Native Win32 Classes
using System;
using System.Runtime.InteropServices;
using System.Text;
/// <summary>
/// Contains native Windows and SetupDi API calls
/// </summary>
public class NativeWin32
{
[Flags]
@mjs3339
mjs3339 / RngJitterSource.cs
Created July 20, 2020 20:52
Detect Entropy Levels from Primitive Data Arrays
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Threading;
public class RngJitterSource : RandomNumberGenerator
{
/// <summary>
/// Recalculate buffer every 1000 milliseconds
/// </summary>
private const int ReSecureThresholdBf = 1000;
@mjs3339
mjs3339 / ProgressGraph.cs
Created April 19, 2020 09:47
Progress Graph Class
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
@mjs3339
mjs3339 / MemoryBitmap.cs
Created April 8, 2020 09:12
Direct Access Pixel Data, GetPixel, SetPixel
using System;
using System.Drawing;
using System.Drawing.Imaging;
public unsafe class MemoryBitmap : IDisposable
{
private readonly BitmapData _bmpData;
private readonly int _depth;
private readonly Bitmap _memoryBitmap;
private readonly byte* _pfp;
private readonly int _stride;
@mjs3339
mjs3339 / SHA3Managed.cs
Created March 24, 2020 21:32
SHA3 Implementation in C#
using System;
using System.Runtime.CompilerServices;
/// <summary>
/// Max size is 768 Bits. Proof: 768 / 8 = 96 * 2 = 192, 200-192=8
/// </summary>
[Serializable]
public class SHA3Managed : HashAlgorithmEx
{
private readonly KeccakSpongeManaged ksm;
public SHA3Managed(int size, ulong[] seed = null) : this(size, 24, seed)
@mjs3339
mjs3339 / UInt512.cs
Created March 24, 2020 09:24
512 Bit Unsigned Integer Structure (C#)
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
[Serializable]
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@mjs3339
mjs3339 / CpuTotalPc.cs
Created March 24, 2020 09:22
Uses the PerformanceCounter to get the Cpu Usage
using System.Diagnostics;
public static class CpuTotalPc
{
private static PerformanceCounter _CPUsage;
public static double CPULoad
{
get
{
if (_CPUsage == null)
try
@mjs3339
mjs3339 / Rdtsc.cs
Created March 24, 2020 09:21
Rdtsc 32 and 64 Bit In C#
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;
public static class Rdtsc
{
[SuppressUnmanagedCodeSecurity]
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate ulong FuncUInt64();
private const uint PAGE_READWRITE = 0x04;
@mjs3339
mjs3339 / JitterEx.cs
Created March 24, 2020 09:20
CPU Jitter Using Rdtsc
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
[Serializable]
public class JitterEx
{
private const int DesaturationLoopLimit = 50;
private const int UpperCpuLoadLimit = 80;
private const int LowerCpuLoadLimit = 20;