Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6176747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:09:21+00:00 2026-05-24T00:09:21+00:00

I want to encrypt some data in a form using jQuery before it’s sent

  • 0

I want to encrypt some data in a form using jQuery before it’s sent to the server, it can be a MD5 hash. It is a small project, so I don’t really need to use SSL.

I have the following JavaScript code where I use $.md5 in the password confirmation info:

    $(document).ready(function() {
        var dataToSend = {};
        dataToSend['action'] = 'signup';
        dataToSend['name'] = name.val();
        dataToSend['email'] = email.val();
        dataToSend['confsenha'] = $.md5(pass2.val());

        var options = {
            target: '#error', 
            url: 'insert.php',
            beforeSubmit: validate,
            data: dataToSend,
            success: function(resposta) {
                $('#message').html(resposta);
            }
        };
        $('#customForm').ajaxForm(options); 
    });

The problem is that the data is being duplicated. I tought that overwriting the data being sent by using the var dataToSend would make ajaxForm send only data in that map. But besides sending data from dataToSend, it also sends data from the form, so what I wanted to encrypt using MD5 appears both encrypted and clean. This is an example of what goes in the request:

usuario=user&email=user%40email.com&senha=12345&confsenha=12345&send=&action=signup&name=user&email=user%40email.com&confsenha=d41d8cd98f00b204e9800998ecf8427e

I know I have to define the a function beforeSerialize, but I don’t know how to manipulate form data. Can anyone tell me how to do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:09:21+00:00Added an answer on May 24, 2026 at 12:09 am

    As per the documentation on the plugin site:

    data
    An object containing extra data that should be submitted
    along with the form.

    The word along is the crux.
    So when you pass data as a part of the options object that data is serialized and is sent along with any data/input elements values that are part of a form.

    A better approach would be to hash the password value and assign it to the same field or another hidden field in the beforeSubmit handler(in your case the validate function) and remove the dataToSend object totally.

    Something like:

    Without any hidden element:

    function validate(){
     //Other Code
      pass2.val($.md5(pass2.val())); 
    }
    

    With a hidden element in the form:

    function validate(){
     //Other Code
      $("#hdnPass").val($.md5(pass2.val()));
      pass2.val(""); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to encrypt some server data using .NET's RSACryptoServiceProvider and decrypt it when
Situation: I want to provide a website service where users can enter some data
As the title says. Using the iPhone SDK, I want to RSA encrypt some
I have a SQL Server database with some sensitive info. I want to encrypt
I want to encrypt some json from a server and then decrypt it on
I'm looking to encrypt some data using multiple ciphers (ie, AES, Serpent, Twofish...), and
I want to compress some files (into the ZIP format) and encrypt them if
I want to encrypt few files using python what is the best way I
My boss wants me to encrypt some information used during data transfer. The individual
I want my application (PHP, but that shouldn't matter) to store some data in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.