hello guys,
my requirement is tht, my login detail (password) should be stored in an encryptd form in DB. and whn i try to retrieve it, it shud go thru decrypt algo. how can i achieve ths?? the other thng is tht: i have to write algo in logic layer in simple form
Here is my code:
login.aspx.cs protected void Button1_Click(object sender, EventArgs e)
{
String strShowName = txtUsrName.Text.ToString();
Session["ShowName"] = strShowName; //session will store username
try
{ string strUserName = txtUsrName.Text;
string strPassword = txtPswd.Text;
logic objBAL = new logic(); //creating object of business layer class
objBAL.userLogin(strUserName, strPassword);}.....
logic.cs: public void userLogin(string strUserName, string strPassword)
{ try
{
datalayer objDAL = new datalayer();//creating DL object
objDAL.userLogin(strUserName, strPassword);
}
datalayer.cs: public void userLogin(string strUserName, string strPassword)
{
sqlconnection.Open();
try
{
SqlCommand cmd = new SqlCommand("UserVerifivation", sqlconnection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@strUserName", strUserName);
cmd.Parameters.AddWithValue("@strPassword", strPassword);
SqlParameter identifyUser = new SqlParameter("@userType", SqlDbType.NVarChar);
identifyUser.Size = 6;
identifyUser.Direction = ParameterDirection.Output;
cmd.Parameters.Add(identifyUser);
cmd.ExecuteNonQuery();
string role = cmd.Parameters["@userType"].Value.ToString();
logic objBAL = new logic();
objBAL.validateUser(role); //calling validateuser method for identifying type of user
}
SP: ALTER PROCEDURE [dbo].[UserVerifivation]
(
@strUserName nvarchar(50) OUTPUT,
@strPassword nvarchar(50),
@userType nchar(50) OUTPUT
)
AS
BEGIN TRY
SET @userType=(SELECT nn_user_type
FROM tb_registration1
WHERE uni_username=@strUserName AND ck_password=@strPassword)
SELECT @userType
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() as ErrorNumber,
ERROR_MESSAGE() as ErrorMessage;
END CATCH