Wednesday, February 2, 2011

Valid hash algorithm names for Crypto.Hash method

For unknown reason an algorithm parameter of System.Web.Helpers.Crypto.Hash method is a string instead of an enumeration value.

To learn which algorithms are available you can try using some unusual name and get InvalidOperationException: The hash algorithm 'md51' is not supported, valid values are: sha256, sha1, md5 message.

So, for example, the code


gives


You can check what calculated MD5 hash is the same as here.

Using this method is much simpler than using classes from System.Security.Cryptography namespace, though the latter provides such hash algorithms as AES, RC2, RSA etc.

No comments:

Post a Comment

Post a Comment