Click here to Skip to main content
15,897,371 members
Articles / Web Development / ASP.NET

Client Side Hashing using JQuery

Rate me:
Please Sign up or sign in to vote.
4.08/5 (7 votes)
2 Jun 2009CPOL2 min read 56.7K   1.1K   17  
Client side text hashing using JQuery
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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></title>

    <script src="jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script src="JScript2.js" type="text/javascript"></script>
    <script type ="text/javascript" >
  $(document).ready(function() {
            $("#Button1").click(function() {
                 var id = $("#TextBox1").val();
                var id2 = $.sha1(String(id));
                $("#TextBox1").val(id2);
            });
              $("#Button2").click(function() {
                 var id = $("#TextBox2").val();
                 var salt ='<%=Session["lid"].ToString() %>';
                var id2 = $.sha1(String(id + salt ));
                $("#TextBox2").val(id2);
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <br />
        Only TextBox value Encryption<br />
        <br />
        <asp:TextBox ID="TextBox1" runat="server" Width="331px"></asp:TextBox>
        <input id="Button1" type="button" value="Click"  />
        <br />
        <br />
        TextBox value with Session value Encryption
        <br />
        <br />
        <asp:TextBox ID="TextBox2" runat="server" Height="20px" Width="329px"></asp:TextBox>
        <input id="Button2" type="button" value="Click" /></div>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
I am from India, currently i am working in Microsoft Platform for building web and mobile applications.

Comments and Discussions