private static HashAlgorithm GetHashAlgorithm(HashAlgorithmName hashAlgorithm)
{
if (hashAlgorithm == HashAlgorithmName.MD5)
return new MD5CryptoServiceProvider();
if (hashAlgorithm == HashAlgorithmName.SHA1)
return new SHA1CryptoServiceProvider();
if (hashAlgorithm == HashAlgorithmName.SHA256)
return new SHA256CryptoServiceProvider();
if (hashAlgorithm == HashAlgorithmName.SHA384)
return new SHA384CryptoServiceProvider();
if (hashAlgorithm == HashAlgorithmName.SHA512)
return new SHA512CryptoServiceProvider();
throw new CryptographicException(NTE_BAD_ALGID);
}