Password Encryption Using ASP.Net

Password Encryption can be used for encrypting password. Here in this article I am going to explain how you can create the hashed passwords. This method can be used for storing passwords in the credentials section of a database or inside an XML file.

Some of commonly used Hash Encryption Algorithms are ‘MD5‘ and ‘SHA-1

SHA-1 (Secure Hash Algorithm 1) is slower than MD5 but the message digest is larger, which makes it more resistant to brute force attacks. Therefore, it is recommended that Secure Hash Algorithm is preferred to MD5 for all of your digest needs.

Creating Hashed Passwords Using “SHA-1” (Secure Hash Algoritham)

  • Source Code “VB.NET”

    Dim strEncryptPassword As String
    strEncryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, “sha1”)

  • Source Code “C#”

    {
    string strEncryptPassword;
    strEncryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, “sha1”);
    }

Advertisements

Forms Authentication timeout in ASP.NET

Asp.Net the forms authentication timeout value by default is 30 Minutes, this means after 30 minutes of inactivity the application will redirect user to the login page again

You can change the timeout value by modifying the web.config

for example:

<authentication mode=”Forms”>
<forms name=”.ASPXFORMSDEMO” loginUrl=”./logon.aspx” protection=”All” path=”/” timeout=”2400″ />
</authentication>

Multiple Forms in ASP.NET

In Asp.net Page we can host exactly one server form. I’ve found one good article on MSDN which related to the Form Based Programming in ASP.NET. So We can employ multiple forms in a asp.net page and only one of them can have the runat attribute set to server. The request for the page is therefore processed as usual using the code built in the page base class. Temporary class for the page is generated, compiled and finally loaded.
You can find the Article at http://msdn.microsoft.com/msdnmag/issues/03/05/CuttingEdge/default.aspx