The code sample can be used in web pages to encrypt a password.The GetEncryptedPassword converts the plain text input to cipher text, in cryptography terminologies. To our use, is the static FormsAuthentication.HashPasswordForStoringInConfigFile() function that takes the plainText and also the algorithm that should be used to encrypt the password.In this example we use the SHA1 algorithm. Technically, the SHA1 algorithm is a hash algorithm and hence returns only a hash of the plaintext. A hashing algorithm one whose input size is not-fixed, but output's size is fixed. this is one way Encryption. you cant decrypt this password
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class PasswordEncription
{
public PasswordEncription()
{
}
public static string GetEncriptedPassword(string plainText)
{
return FormsAuthentication.HashPasswordForStoringInConfigFile(plainText, "SHA1");
}
}
No comments:
Post a Comment