public static CryptographyProvider Create( [CanBeNull] XElement configuration, [NotNull] string name) { using (IDisposable provider = (IDisposable)CryptoConfig.CreateFromName(name)) { AsymmetricAlgorithm asymm = provider as AsymmetricAlgorithm; if (asymm != null) { return(AsymmetricCryptographyProvider.Create(asymm, configuration)); } SymmetricAlgorithm sym = provider as SymmetricAlgorithm; if (sym != null) { return(SymmetricCryptographyProvider.Create(name, sym, configuration)); } System.Security.Cryptography.HashAlgorithm hash = provider as System.Security.Cryptography.HashAlgorithm; if (hash != null) { return(HashingCryptographyProvider.Create(name, hash, configuration)); } RandomNumberGenerator rnd = provider as RandomNumberGenerator; if (rnd != null) { return(RandomCryptographyProvider.Create(name, rnd, configuration)); } throw new CryptographicException( string.Format(Resources.CryptographyProvider_Create_Unknown_Provider, name)); } }
public static byte[] GetHash([NotNull] this Stream inputStream, [CanBeNull] HashAlgorithm algorithm = null) => HashingCryptographyProvider.GetHash(inputStream, algorithm);
public static string GetHashString([NotNull] this byte[] buffer, int offset = 0, int count = -1, [CanBeNull] HashAlgorithm algorithm = null) => HashingCryptographyProvider.GetHashString(buffer, offset, count, algorithm);
public static string GetHashString([NotNull] this string input, [CanBeNull] HashAlgorithm algorithm = null) => HashingCryptographyProvider.GetHashString(input, algorithm);