Friday, April 22, 2022

Encryption of password with Form Authentication and other techniques

System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("Yash@123", "md5").ToLower()

FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "SHA1");

------------------------------------------------

C# code

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;


public partial class DecryptPassword : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        

    }


    protected void btnDecrypt_Click(object sender, EventArgs e)

    {


        //txtDecrypt.Text = LuminousSecurity.Encryption.Encrypt(txtPassword.Text);

        //txtDecrypt.Text = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "md5");


        


        

        //txtDecrypt.Text= LuminiousUtility.Util.Utility.DecodePassword(txtPassword.Text);

    }


    protected void btnDecryptWithKey_Click(object sender, EventArgs e)

    {

        txtDecryptWithKey.Text = LuminousSecurity.Encryption.DecryptString(txtPassword.Text.Trim(), "lumbibthabik");

    }


    


    protected void btnDecode_Click(object sender, EventArgs e)

    {

        txtDecode.Text = LuminiousUtility.Util.Utility.DecodePassword(txtPassword.Text);

    }


    protected void btnEncrypt_Click(object sender, EventArgs e)

    {

        txtEncrypt.Text = LuminousSecurity.Encryption.Encrypt(txtPassword.Text);

    }


    protected void btnDecrypt_Click1(object sender, EventArgs e)

    {

        txtDecrypt.Text = LuminousSecurity.Encryption.Decrypt(txtPassword.Text);

    }


    protected void btnGenerate_Click(object sender, EventArgs e)

    {


    }


    protected void btnEncryptWithKey_Click(object sender, EventArgs e)

    {

        txtEncryptWithKey.Text = LuminousSecurity.Encryption.EncryptData(txtPassword.Text.Trim(), "lumbibthabik");

    }


    protected void btnEncode_Click(object sender, EventArgs e)

    {

        txtEncode.Text = LuminiousUtility.Util.Utility.EncodePassword(txtPassword.Text);

    }


    protected void btnMD5Encrypt_Click(object sender, EventArgs e)

    {

        txtMD5Encrypt.Text =  System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "SHA1").ToString();


//        txtMD5Encrypt.Text =  System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "MD5").ToString();

    }

}

----------------------------------

cs file code

 <asp:TextBox runat="server" ID="txtPassword" Width="200px"/>

    <asp:Button runat="server" ID="btnGenerate" OnClick="btnGenerate_Click" Text="generate"/>

    <br />

    <asp:Label runat="server" ID="lblDecryptwithkey" Text="Decypt with Key" />

    <asp:TextBox runat="server" ID="txtDecryptWithKey" Width="500px" Text="test" />

    <asp:Button runat="server" ID="btnDecryptWithKey" OnClick="btnDecryptWithKey_Click" Text="Decrypt with key"/>

    <br />

    <asp:Label runat="server" ID="lblencryptwithkey" Text="Encrypt with Key" />

    <asp:TextBox runat="server" ID="txtEncryptWithKey" Width="500px" Text="test" />

    <asp:Button runat="server" ID="btnEncryptWithKey" OnClick="btnEncryptWithKey_Click" Text="Encrypt with key"/>

    <br />

    <asp:Label runat="server" ID="lblEncrypt" Text="Encrypt" />

    <asp:TextBox runat="server" ID="txtEncrypt" Width="500px" Text="test" />

    <asp:Button runat="server" ID="btnEncrypt" OnClick="btnEncrypt_Click" Text="Encrypt"/>

    <br />

    <asp:Label runat="server" ID="lblDecrypt" Text="Decrypt" />

    <asp:TextBox runat="server" ID="txtDecrypt" Width="500px" Text="test" />

    <asp:Button runat="server" ID="btnDecrypt" OnClick="btnDecrypt_Click1" Text="Decrypt"/>

    <br />

    <asp:Label runat="server" ID="lblDecode" Text="Decode" />

    <asp:TextBox runat="server" ID="txtDecode" Width="500px" Text="test" />

    <asp:Button runat="server" ID="btnDecode" OnClick="btnDecode_Click" Text="Decode"/>

    <br />

    <asp:Label runat="server" ID="lblEncode" Text="Encode" />

    <asp:TextBox runat="server" ID="txtEncode" Width="500px" Text="test" />

    <asp:Button runat="server" ID="btnEncode" OnClick="btnEncode_Click" Text="Encode"/>

    <br />

    <asp:Label runat="server" ID="lblMD5Encrypt" Text="MD5 Encrypt" />

    <asp:TextBox runat="server" ID="txtMD5Encrypt" Width="500px" Text="test" />

    <asp:Button runat="server" ID="btnMD5Encrypt" OnClick="btnMD5Encrypt_Click" Text="Encode"/>


------------------------------------

or you can use below link

https://www.c-sharpcorner.com/UploadFile/f50501/password-encryption-for-forms-authentication-in-Asp-Net/


https://www.csharpcodi.com/csharp-examples/System.Web.Security.FormsAuthentication.Decrypt(string)/


https://topic.alibabacloud.com/a/go-to-c--encrypt-and-font-colorreddecryptfont-user-passwords-using-font-colorredmd5font_1_38_30853985.html

No comments:

Post a Comment