You must Sign In to post a response.
  • Category: ASP.NET

    How to encrypt textbox value?


    how to encrypt textbox value?
    how to decrypt textbox value?

    Advance Wishes!!
    Ramesh m
  • #498360
    what is your exact need
    you want to encrapt password?
    tell me

    “Talent wins games, but teamwork and intelligence wins championships.”

  • #498382
    Refer this link

  • #498406
    Hi Ramesh M

    You can use any encryption algorithm.

    ASP.Net has an in-built mechanism for encrypting text, you can use that also.

    Please check this code:

    string EncryptedText = FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text, "MD5");

    Thanks & Regards
    Paritosh Mohapatra

    Thanks & Regards
    Paritosh Mohapatra
    Microsoft MVP (ASP.Net/IIS)
    DotNetSpider MVM

  • #498440
    check my article for the same.

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #498552
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

    <html xmlns="" >
    <head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    <asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 72px; position: absolute;
    top: 115px"></asp:TextBox>
    <asp:Button ID="ButtonEncrypt" runat="server" OnClick="ButtonEncrypt_Click" Style="z-index: 101;
    left: 158px; position: absolute; top: 144px" Text="Encrypt" />
    <asp:Label ID="lblCypher" runat="server" Style="z-index: 102; left: 77px; position: absolute;
    top: 180px" Text="Label"></asp:Label>
    <asp:Label ID="lblPlain" runat="server" Style="z-index: 105; left: 493px; position: absolute;
    top: 148px" Text="Label"></asp:Label>
    <asp:Button ID="ButtonDecrypt" runat="server" Style="z-index: 104; left: 461px; position: absolute;
    top: 118px" Text="Decrypt" OnClick="ButtonDecrypt_Click" />


    And the code follows.
    It is too simple that it doesnt require any explanation.

    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 partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void ButtonEncrypt_Click(object sender, EventArgs e)
    string s = TextBox1.Text,Cypher="";
    for (int i = 0; i < s.Length; i++)
    char c = (char)(s[i] + 2);
    Cypher = Cypher + new string(c, 1);
    lblCypher.Text = Cypher;
    protected void ButtonDecrypt_Click(object sender, EventArgs e)
    string s = lblCypher.Text, PlainText= "";
    for (int i = 0; i < s.Length; i++)
    char c = (char)(s[i] - 2);
    PlainText = PlainText + new string(c, 1);
    lblPlain.Text = PlainText;



    Naveen Kumar.M

  • #498819
    Go through :

    Thanks & regards,
    Gaurav Kumar Arora
    Site Coordinator - DNS
    My blog -

  • #498861
    Nothing is Impossible... :)

    My Forum :

  • #499492

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.