using System.Collections.Generic;
using System.Security.Cryptography;
const int LOTTERY_MAX = 60;
SHA256 Sha256 = SHA256.Create();
public static void Main()
RandomNumberGenerator rng = RandomNumberGenerator.Create();
SHA256 sha256 = SHA256.Create();
byte[] random = new Byte[32];
Console.WriteLine("my Rand: " + BitConverter.ToString(random));
Console.WriteLine("my Commitment: " + BitConverter.ToString(sha256.ComputeHash(random)));
List<byte[]> seeds = new List<byte[]>
new Byte[] {0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
new Byte[] {0x10, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
new Byte[] {0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
new Byte[] {0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
byte[] combinedSeed = new Byte[32]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
for(int i = 0; i < 32; i++)
foreach(byte[] seed in seeds)
combinedSeed[i] ^= seed[i];
Console.WriteLine("my out: " + BitConverter.ToString(combinedSeed));
Console.WriteLine(RandomNumbers.Rand(combinedSeed, 1, 59));
public static class RandomNumbers
static RandomNumberGenerator rng = RandomNumberGenerator.Create();
static SHA256 sha256 = SHA256.Create();
public static uint Rand(byte[] seed)
return BitConverter.ToUInt32(seed, 0);
public static uint Rand(byte[] seed, uint max)
throw new ArgumentOutOfRangeException("max", "max must be greater than 0");
if (rand < (uint.MaxValue - uint.MaxValue % max))
seed = sha256.ComputeHash(seed);
public static uint Rand(byte[] seed, uint min, uint max)
throw new ArgumentOutOfRangeException("min", "max must be greater than min");
return min + Rand(seed, max - min);