Application blocks in enterprise library 5.0 simplifies the application development.....
Introduction
In the last article( Encryption and Decryption using Cryptography Application block in Enterprise Library 5.0(part 1))we saw encryption and decryption using symmetric cryptography providers. Now we will see the use of hash providers.
Using a Hash Provider to Store a One-Way Hashed Text
Here we use a one-way hashing algorithm to encrypt a string. So first we have to configure web.config. Select " Add cryptography Settings" from the block menu as shown below:

Click the plus sign icon in the Hash Providers column, point to Add Hash Providers, and click Add Hash Algorithm Provider.

A dialog box is displayed. Expand the mscorlib entry until you see a list of providers, and select SHA1Managed. Then click OK.

Back in the configuration tool, change the Name property of the hashing provider. In my example I changed the name to SHA1(not in the picture). Salt Enabled property is set to True.

Save the application configuration.
Now the code
First add the reference:
? Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll
aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server" ID="txt1"></asp:TextBox>
<asp:Button runat="server" ID="btn1" text="submit" onclick="btn1_Click"/><br />
<asp:Label ID="lbl1" runat="server" />
</div>
</form>
</body>
</html>
aspx.cs
using System;
using Microsoft.Practices.EnterpriseLibrary.Security.Cryptography;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn1_Click(object sender, EventArgs e)
{
string Hash = "SHA1";
string plainText = txt1.Text;
lbl1.Text = Cryptographer.CreateHash(Hash, plainText);
}
}
Conclusion
Hope this article helps you.................