Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

How to access string before encryption in c#

$
0
0

Hi all

     I am encrypting a password on client side. I want to access it before encryption. How to do that. Below is my code, how I am encrypting the password.

    

<script type="text/javascript" src="../js/md5.js"></script>  <script type="text/javascript">
       function GeneratePwd() {
           if (document.getElementById("txtpassword").value != "")
            {
                document.getElementById("txtDistance").value = document.getElementById("txtpassword").value;
               document.getElementById("txtpassword").value = hex_md5(document.getElementById("txtpassword").value);
           }
       }  </script> 

aspx

<asp:TextBox ID="txtpassword" runat="server" CssClass="mytextbox" TextMode="Password"></asp:TextBox>
<asp:RegularExpressionValidator ID="Regex2" runat="server" ControlToValidate="txtpassword"
                                ValidationExpression="^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$"
                                ErrorMessage="Minimum 8 characters atleast 1 Alphabet, 1 Number and 1 Special Character"
                                ForeColor="Red" Display="Static" onpropertychange=" validateCheck()"></asp:RegularExpressionValidator><asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />

code file

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Button1.Attributes.Add("onclick", "return GeneratePwd();");
        }


     
    }

How can I achieve this?

I am doing this because after encryption the textbox get filled with the encrypted string and doesn't match with my RegularExpressionValidator. So I make a method in c# so that I can confirm the password complexity.

After encryption it is not possible to make RegularExpressionValidator  to work, because textbox is having encrypted string which doesn't meet myRegularExpressionValidator  requirement.


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>