private static Func <HashAlgorithm> GetHashAlgorithm(ShaTypes type, int hashSizeInBits) { return(type switch { ShaTypes.Sha1 => () => new SHA1CryptoServiceProvider(), ShaTypes.Sha224 => () => new SHA224CryptoServiceProvider(), ShaTypes.Sha256 => () => new SHA256CryptoServiceProvider(), ShaTypes.Sha384 => () => new SHA384CryptoServiceProvider(), ShaTypes.Sha512 => () => new SHA512CryptoServiceProvider(), ShaTypes.Sha512Bit224 => () => new SHA512tCryptoServiceProvider(hashSizeInBits), ShaTypes.Sha512Bit256 => () => new SHA512tCryptoServiceProvider(hashSizeInBits), ShaTypes.Sha3Bit224 => () => new SHA3CryptoServiceProvider(hashSizeInBits), ShaTypes.Sha3Bit256 => () => new SHA3CryptoServiceProvider(hashSizeInBits), ShaTypes.Sha3Bit384 => () => new SHA3CryptoServiceProvider(hashSizeInBits), ShaTypes.Sha3Bit512 => () => new SHA3CryptoServiceProvider(hashSizeInBits), _ => () => new SHA1CryptoServiceProvider() });
public static ISHA Create(ShaTypes type = ShaTypes.Sha1) => Factory.Create(type);
internal ShaFunction(ShaTypes type) { HashType = type; HashSizeInBits = (int)type % 1000; }
public ShaBlockTransformer(ShaTypes type) { _hashSizeInBits = (int)type % 1000; _internalAlgorithmFactory = GetHashAlgorithm(type, _hashSizeInBits); }
public static ISHA Create(ShaTypes type = ShaTypes.Sha1) => new ShaFunction(type);