Initial commit

This commit is contained in:
Trevor Hall 2026-03-03 23:53:04 -05:00
commit 5584446828
37 changed files with 7962 additions and 0 deletions

35
Shared/RandomNumbers.cs Normal file
View file

@ -0,0 +1,35 @@
/*
* Secucore
*
* Copyright (C) 2023 Trevor Hall
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license.
*
*/
using System.Security.Cryptography;
using System;
namespace SecuCore.Shared
{
class RandomNumbers
{
public static ushort GetNext16()
{
byte[] ib = RandomNumberGenerator.GetBytes(2);
return BitConverter.ToUInt16(ib);
}
public static int GetNext(int min, int max)
{
byte[] ib = RandomNumberGenerator.GetBytes(4);
int ival = BitConverter.ToInt32(ib, 0);
ival = (ival >= 0 ? ival : -ival);
int ceil = max + 1;
int diff = ceil - min;
int rn = ival % diff;
return min + rn;
}
}
}