Home All Groups Group Topic Archive Search About

Newbie Question - List of all available hash algorithms?

Author
3 Jun 2005 9:04 PM
Eric
Hello,

I'm playing around with encryption/decryption, and I am trying to find all
the hashing algorithms that are available to .NET.  Specifically, I'm trying
to get all possibilities for the PasswordDeriveBytes.HashName property.  (I
couldn't find it on MSDN.)

Thank you,

Eric

Author
4 Jun 2005 10:19 AM
Dominick Baier [DevelopMentor]
Hello Eric,

by looking at the source with reflector - there is a HashTable with all available
algorithms. [0]

by experimentation - i found these to work (the others even produce a nasty
dialog box - so be careful if noone on your server is there to press enter
:))

MD5
SHA1
SHA256
SHA384
SHA512
HMACSHA1



[1]

private static Hashtable CreateDefaultMappingHT()
{
      Hashtable hashtable1 = new Hashtable();
      hashtable1.Add("RandomNumberGenerator", CryptoConfig.RNGCryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.RandomNumberGenerator",
CryptoConfig.RNGCryptoServiceProviderType);
      hashtable1.Add("SHA", CryptoConfig.SHA1CryptoServiceProviderType);
      hashtable1.Add("SHA1", CryptoConfig.SHA1CryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.SHA1", CryptoConfig.SHA1CryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.HashAlgorithm", CryptoConfig.SHA1CryptoServiceProviderType);
      hashtable1.Add("MD5", CryptoConfig.MD5CryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.MD5", CryptoConfig.MD5CryptoServiceProviderType);
      hashtable1.Add("SHA256", CryptoConfig.SHA256ManagedType);
      hashtable1.Add("SHA-256", CryptoConfig.SHA256ManagedType);
      hashtable1.Add("System.Security.Cryptography.SHA256", CryptoConfig.SHA256ManagedType);
      hashtable1.Add("SHA384", CryptoConfig.SHA384ManagedType);
      hashtable1.Add("SHA-384", CryptoConfig.SHA384ManagedType);
      hashtable1.Add("System.Security.Cryptography.SHA384", CryptoConfig.SHA384ManagedType);
      hashtable1.Add("SHA512", CryptoConfig.SHA512ManagedType);
      hashtable1.Add("SHA-512", CryptoConfig.SHA512ManagedType);
      hashtable1.Add("System.Security.Cryptography.SHA512", CryptoConfig.SHA512ManagedType);
      hashtable1.Add("System.Security.Cryptography.KeyedHashAlgorithm", CryptoConfig.HMACSHA1Type);
      hashtable1.Add("HMACSHA1", CryptoConfig.HMACSHA1Type);
      hashtable1.Add("System.Security.Cryptography.HMACSHA1", CryptoConfig.HMACSHA1Type);
      hashtable1.Add("MACTripleDES", CryptoConfig.MAC3DESType);
      hashtable1.Add("System.Security.Cryptography.MACTripleDES", CryptoConfig.MAC3DESType);
      hashtable1.Add("RSA", CryptoConfig.RSACryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.RSA", CryptoConfig.RSACryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.AsymmetricAlgorithm",
CryptoConfig.RSACryptoServiceProviderType);
      hashtable1.Add("DSA", CryptoConfig.DSACryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.DSA", CryptoConfig.DSACryptoServiceProviderType);
      hashtable1.Add("DES", CryptoConfig.DESCryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.DES", CryptoConfig.DESCryptoServiceProviderType);
      hashtable1.Add("3DES", CryptoConfig.TripleDESCryptoServiceProviderType);
      hashtable1.Add("TripleDES", CryptoConfig.TripleDESCryptoServiceProviderType);
      hashtable1.Add("Triple DES", CryptoConfig.TripleDESCryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.TripleDES", CryptoConfig.TripleDESCryptoServiceProviderType);
      hashtable1.Add("RC2", CryptoConfig.RC2CryptoServiceProviderType);
      hashtable1.Add("System.Security.Cryptography.RC2", CryptoConfig.RC2CryptoServiceProviderType);
      hashtable1.Add("Rijndael", CryptoConfig.RijndaelManagedType);
      hashtable1.Add("System.Security.Cryptography.Rijndael", CryptoConfig.RijndaelManagedType);
      hashtable1.Add("System.Security.Cryptography.SymmetricAlgorithm", CryptoConfig.RijndaelManagedType);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig#dsa-sha1", CryptoConfig.DSASignatureDescriptionType);
      hashtable1.Add("System.Security.Cryptography.DSASignatureDescription",
CryptoConfig.DSASignatureDescriptionType);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig#rsa-sha1", CryptoConfig.RSAPKCS1SHA1SignatureDescriptionType);
      hashtable1.Add("System.Security.Cryptography.RSASignatureDescription",
CryptoConfig.RSAPKCS1SHA1SignatureDescriptionType);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig#sha1", CryptoConfig.SHA1CryptoServiceProviderType);
      hashtable1.Add("http://www.w3.org/TR/2001/REC-xml-c14n-20010315", "System.Security.Cryptography.Xml.XmlDsigC14NTransform,
System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null,
Version=" + CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments",
"System.Security.Cryptography.Xml.XmlDsigC14NWithCommentsTransform, System.Security,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null, Version="
+ CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig#base64", "System.Security.Cryptography.Xml.XmlDsigBase64Transform,
System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null,
Version=" + CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/TR/1999/REC-xpath-19991116", "System.Security.Cryptography.Xml.XmlDsigXPathTransform,
System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null,
Version=" + CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/TR/1999/REC-xslt-19991116", "System.Security.Cryptography.Xml.XmlDsigXsltTransform,
System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null,
Version=" + CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig#enveloped-signature",
"System.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform, System.Security,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null, Version="
+ CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig# X509Data", "System.Security.Cryptography.Xml.KeyInfoX509Data,
System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Version="
+ CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig# KeyName", "System.Security.Cryptography.Xml.KeyInfoName,
System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Version="
+ CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig# KeyValue/DSAKeyValue",
"System.Security.Cryptography.Xml.DSAKeyValue, System.Security, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, Version=" + CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig# KeyValue/RSAKeyValue",
"System.Security.Cryptography.Xml.RSAKeyValue, System.Security, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, Version=" + CryptoConfig._Version);
      hashtable1.Add("http://www.w3.org/2000/09/xmldsig# RetrievalMethod",
"System.Security.Cryptography.Xml.KeyInfoRetrievalMethod, System.Security,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Version=" + CryptoConfig._Version);
      return hashtable1;
}

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

Show quoteHide quote
> Hello,
>
> I'm playing around with encryption/decryption, and I am trying to find
> all the hashing algorithms that are available to .NET.  Specifically,
> I'm trying to get all possibilities for the
> PasswordDeriveBytes.HashName property.  (I couldn't find it on MSDN.)
>
> Thank you,
>
> Eric
>
Are all your drivers up to date? click for free checkup

Author
16 Jun 2005 2:51 PM
Eric
Thanks, Dominick!


Show quoteHide quote
"Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com>
wrote in message news:444510632534843899488269@news.microsoft.com...
> Hello Eric,
>
> by looking at the source with reflector - there is a HashTable with all
available
> algorithms. [0]
>
> by experimentation - i found these to work (the others even produce a
nasty
> dialog box - so be careful if noone on your server is there to press enter
> :))
>
> MD5
> SHA1
> SHA256
> SHA384
> SHA512
> HMACSHA1
>
>
>
> [1]
>
> private static Hashtable CreateDefaultMappingHT()
> {
>       Hashtable hashtable1 = new Hashtable();
>       hashtable1.Add("RandomNumberGenerator",
CryptoConfig.RNGCryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.RandomNumberGenerator",
> CryptoConfig.RNGCryptoServiceProviderType);
>       hashtable1.Add("SHA", CryptoConfig.SHA1CryptoServiceProviderType);
>       hashtable1.Add("SHA1", CryptoConfig.SHA1CryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.SHA1",
CryptoConfig.SHA1CryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.HashAlgorithm",
CryptoConfig.SHA1CryptoServiceProviderType);
>       hashtable1.Add("MD5", CryptoConfig.MD5CryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.MD5",
CryptoConfig.MD5CryptoServiceProviderType);
>       hashtable1.Add("SHA256", CryptoConfig.SHA256ManagedType);
>       hashtable1.Add("SHA-256", CryptoConfig.SHA256ManagedType);
>       hashtable1.Add("System.Security.Cryptography.SHA256",
CryptoConfig.SHA256ManagedType);
>       hashtable1.Add("SHA384", CryptoConfig.SHA384ManagedType);
>       hashtable1.Add("SHA-384", CryptoConfig.SHA384ManagedType);
>       hashtable1.Add("System.Security.Cryptography.SHA384",
CryptoConfig.SHA384ManagedType);
>       hashtable1.Add("SHA512", CryptoConfig.SHA512ManagedType);
>       hashtable1.Add("SHA-512", CryptoConfig.SHA512ManagedType);
>       hashtable1.Add("System.Security.Cryptography.SHA512",
CryptoConfig.SHA512ManagedType);
>       hashtable1.Add("System.Security.Cryptography.KeyedHashAlgorithm",
CryptoConfig.HMACSHA1Type);
>       hashtable1.Add("HMACSHA1", CryptoConfig.HMACSHA1Type);
>       hashtable1.Add("System.Security.Cryptography.HMACSHA1",
CryptoConfig.HMACSHA1Type);
>       hashtable1.Add("MACTripleDES", CryptoConfig.MAC3DESType);
>       hashtable1.Add("System.Security.Cryptography.MACTripleDES",
CryptoConfig.MAC3DESType);
>       hashtable1.Add("RSA", CryptoConfig.RSACryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.RSA",
CryptoConfig.RSACryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.AsymmetricAlgorithm",
> CryptoConfig.RSACryptoServiceProviderType);
>       hashtable1.Add("DSA", CryptoConfig.DSACryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.DSA",
CryptoConfig.DSACryptoServiceProviderType);
>       hashtable1.Add("DES", CryptoConfig.DESCryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.DES",
CryptoConfig.DESCryptoServiceProviderType);
>       hashtable1.Add("3DES",
CryptoConfig.TripleDESCryptoServiceProviderType);
>       hashtable1.Add("TripleDES",
CryptoConfig.TripleDESCryptoServiceProviderType);
>       hashtable1.Add("Triple DES",
CryptoConfig.TripleDESCryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.TripleDES",
CryptoConfig.TripleDESCryptoServiceProviderType);
>       hashtable1.Add("RC2", CryptoConfig.RC2CryptoServiceProviderType);
>       hashtable1.Add("System.Security.Cryptography.RC2",
CryptoConfig.RC2CryptoServiceProviderType);
>       hashtable1.Add("Rijndael", CryptoConfig.RijndaelManagedType);
>       hashtable1.Add("System.Security.Cryptography.Rijndael",
CryptoConfig.RijndaelManagedType);
>       hashtable1.Add("System.Security.Cryptography.SymmetricAlgorithm",
CryptoConfig.RijndaelManagedType);
>       hashtable1.Add("http://www.w3.org/2000/09/xmldsig#dsa-sha1",
CryptoConfig.DSASignatureDescriptionType);
>
hashtable1.Add("System.Security.Cryptography.DSASignatureDescription",
> CryptoConfig.DSASignatureDescriptionType);
>       hashtable1.Add("http://www.w3.org/2000/09/xmldsig#rsa-sha1",
CryptoConfig.RSAPKCS1SHA1SignatureDescriptionType);
>
hashtable1.Add("System.Security.Cryptography.RSASignatureDescription",
> CryptoConfig.RSAPKCS1SHA1SignatureDescriptionType);
>       hashtable1.Add("http://www.w3.org/2000/09/xmldsig#sha1",
CryptoConfig.SHA1CryptoServiceProviderType);
>       hashtable1.Add("http://www.w3.org/TR/2001/REC-xml-c14n-20010315",
"System.Security.Cryptography.Xml.XmlDsigC14NTransform,
> System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
Custom=null,
> Version=" + CryptoConfig._Version);
>
hashtable1.Add("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments
",
> "System.Security.Cryptography.Xml.XmlDsigC14NWithCommentsTransform,
System.Security,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null, Version="
> + CryptoConfig._Version);
>       hashtable1.Add("http://www.w3.org/2000/09/xmldsig#base64",
"System.Security.Cryptography.Xml.XmlDsigBase64Transform,
> System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
Custom=null,
> Version=" + CryptoConfig._Version);
>       hashtable1.Add("http://www.w3.org/TR/1999/REC-xpath-19991116",
"System.Security.Cryptography.Xml.XmlDsigXPathTransform,
> System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
Custom=null,
> Version=" + CryptoConfig._Version);
>       hashtable1.Add("http://www.w3.org/TR/1999/REC-xslt-19991116",
"System.Security.Cryptography.Xml.XmlDsigXsltTransform,
> System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
Custom=null,
> Version=" + CryptoConfig._Version);
>
hashtable1.Add("http://www.w3.org/2000/09/xmldsig#enveloped-signature",
> "System.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform,
System.Security,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null, Version="
> + CryptoConfig._Version);
>       hashtable1.Add("http://www.w3.org/2000/09/xmldsig# X509Data",
"System.Security.Cryptography.Xml.KeyInfoX509Data,
> System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
Version="
> + CryptoConfig._Version);
>       hashtable1.Add("http://www.w3.org/2000/09/xmldsig# KeyName",
"System.Security.Cryptography.Xml.KeyInfoName,
Show quoteHide quote
> System.Security, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
Version="
> + CryptoConfig._Version);
>       hashtable1.Add("http://www.w3.org/2000/09/xmldsig#
KeyValue/DSAKeyValue",
> "System.Security.Cryptography.Xml.DSAKeyValue, System.Security,
Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a, Version=" + CryptoConfig._Version);
>       hashtable1.Add("http://www.w3.org/2000/09/xmldsig#
KeyValue/RSAKeyValue",
> "System.Security.Cryptography.Xml.RSAKeyValue, System.Security,
Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a, Version=" + CryptoConfig._Version);
>       hashtable1.Add("http://www.w3.org/2000/09/xmldsig# RetrievalMethod",
> "System.Security.Cryptography.Xml.KeyInfoRetrievalMethod, System.Security,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Version=" +
CryptoConfig._Version);
>       return hashtable1;
> }
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
> > Hello,
> >
> > I'm playing around with encryption/decryption, and I am trying to find
> > all the hashing algorithms that are available to .NET.  Specifically,
> > I'm trying to get all possibilities for the
> > PasswordDeriveBytes.HashName property.  (I couldn't find it on MSDN.)
> >
> > Thank you,
> >
> > Eric
> >
>
>
>

Bookmark and Share