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

    How to encrypt textbox value?

    hi,

    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.”
    umardaraj07@gmail.com

  • #498382
    Refer this link

    http://www.dotnetspider.com/forum/185122-Encrypt-Decrypt-password-C-net.aspx

  • #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");
    Response.Write(EncryptedText);

    Thanks & Regards
    Paritosh Mohapatra


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

  • #498440
    check my article for the same.


    http://mannpandey.blogspot.com/2009/07/code-encryption-and-decryption-using.html

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #498552
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <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" />

    </div>
    </form>
    </body>
    </html>





    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;

    }
    }

    Regards,

    Naveen Kumar.M

  • #498819
    Go through :

    http://www.google.com/search?rlz=1C1GGLS_enIN341IN341&sourceid=chrome&ie=UTF-8&q=encrypt+password
    [/code

    Thanks & regards,
    Gaurav Kumar Arora
    Site Coordinator - DNS
    My blog - http://gaurav-arora.com

  • #498861
    http://www.dotnetspider.com/resources/37848-Encrypt-Decript-String-ASP-NET.aspx
    Nothing is Impossible... :)

    My Forum :http://www.dotnetobject.com

  • #499492
    http://www.dotnetspider.com/forum/185122-Encrypt-Decrypt-password-C-net.aspx


  • 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.