View INotifyPropertyChangedEx.cs
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
namespace ComponentModelEx | |
{ | |
public delegate void PropertyChangedExEventHandler(object sender, PropertyChangedExEventArgs e); | |
public interface INotifyPropertyChangedEx | |
{ | |
event PropertyChangedExEventHandler PropertyChangedEx; | |
} | |
} |
View DictionaryChangedEventArgs.cs
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
using System; | |
using System.Collections.Generic; | |
namespace ComponentModelEx | |
{ | |
public class DictionaryChangedEventArgs<TKey, TValue> : EventArgs | |
{ | |
public DictionaryChangedAction Action => _action; | |
public KeyValuePair<TKey, TValue> OldValue => _oldValue; | |
public KeyValuePair<TKey, TValue> NewValue => _newValue; |
View IsValidIPv6Address.cs
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 bool IPv6Check(string input) | |
{ | |
if (string.IsNullOrWhiteSpace(input)) | |
{ | |
return false; | |
} | |
if (input.IndexOf("::") != input.LastIndexOf("::")) // 'The "::" can only appear once in an address.' | |
{ | |
return false; |
View GenericArithmeticFactory.cs
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 GenericArithmeticFactory<T> | |
{ | |
private static Dictionary<ExpressionType, Func<T, T, T>> _binaryOperationDictionary; | |
private static Func<T, T> _sqrtOperation = null; | |
static GenericArithmeticFactory() | |
{ | |
_binaryOperationDictionary = new Dictionary<ExpressionType, Func<T, T, T>>(); | |
} |
View PasswordHashing.cs
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> | |
/// Requires the BCrypt nuget package. Available here: https://www.nuget.org/packages/BCrypt.Net-Next | |
/// </summary> | |
public static class PasswordHashing | |
{ | |
public static string HashPassword(string password, int workFactor) | |
{ | |
return BCrypt.Net.BCrypt.HashPassword(password, workFactor); | |
} |
View FastFactorial.cs
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 FastFactorial | |
{ | |
public static BigInteger Factorial(BigInteger n) | |
{ | |
return MultiplyRange(2, n); | |
} | |
private static BigInteger MultiplyRange(BigInteger from, BigInteger to) | |
{ | |
var diff = to - from; |
View NumberTheory.Maths.cs
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
using System; | |
using System.Linq; | |
using System.Numerics; | |
using System.Collections.Generic; | |
public static class Maths | |
{ | |
/// <summary> | |
/// Legendre Symbol returns 1 for a (nonzero) quadratic residue mod p, -1 for a non-quadratic residue (non-residue), or 0 on zero. | |
/// </summary> |
View CryptoRandomSingleton.cs
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> | |
/// Cryptographically secure random number generator. Features a safe, secure, and correct implementation. | |
/// Numbers are evenly distributed across the whole range; avoids modulo bias. | |
/// Internal buffers always cleared after every value returned--leaves nothing in memory. | |
/// Singleton intended to be instantiated only once for the lifetime of the application. | |
/// Remember to call Dispose when no longer needed. | |
/// </summary> | |
public static class CryptoRandomSingleton | |
{ |
View ANS1PrivateKey.cs
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 ANS1PrivateKey : IDisposable | |
{ | |
public BigInteger Modulus = BigInteger.MinusOne; | |
public BigInteger Exponent = BigInteger.MinusOne; | |
public BigInteger P = BigInteger.MinusOne; | |
public BigInteger Q = BigInteger.MinusOne; | |
public BigInteger D = BigInteger.MinusOne; | |
public BigInteger DP = BigInteger.MinusOne; | |
public BigInteger DQ = BigInteger.MinusOne; | |
public BigInteger InverseQ = BigInteger.MinusOne; |
View Factorization.cs
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
using System.Numerics; | |
public static class Factorization | |
{ | |
private static BigInteger _cacheCeiling; | |
private static List<BigInteger> _primeCache; | |
private static BigInteger _cacheLargestPrimeCurrently; | |
private static BigInteger[] _probablePrimeCheckBases; | |
static Factorization() |
NewerOlder