Title: netrose's Replies | WordPress.org

---

# netrose

  [  ](https://wordpress.org/support/users/netrose/)

 *   [Profile](https://wordpress.org/support/users/netrose/)
 *   [Topics Started](https://wordpress.org/support/users/netrose/topics/)
 *   [Replies Created](https://wordpress.org/support/users/netrose/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/netrose/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/netrose/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/netrose/engagements/)
 *   [Favorites](https://wordpress.org/support/users/netrose/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Encrypting Data on Client Side Before Submission](https://wordpress.org/support/topic/encrypting-data-on-client-side-before-submission/)
 *  Thread Starter [netrose](https://wordpress.org/support/users/netrose/)
 * (@netrose)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/encrypting-data-on-client-side-before-submission/#post-17004824)
 * That code only changes the input field type to a password field, it doesn’t encrypt
   the data being sent. I managed to find a solution. To intercept and encrypt text-
   1 field, I managed to intercept the ajax request, then I had to encrypt the password
   synchronously so that the function waiting for a return didn’t throw any errors.
 *     ```wp-block-code
       function syncMethod(settings) {
           try {
               var password = settings.data.get('text-1');
               const encryptedPassword = window.syncEncryptPassword(publicKey, password);
               settings.data.set('text-1', encryptedPassword);
               return settings;
           } catch (error) {
               console.log("Error: ", error);
               return settings;
           }
       }
   
       jQuery(document).ready(function($) {
           var originalAjaxFunction = $.ajax;
           $.ajax = function(settings) {
               if (settings.url.indexOf('admin-ajax.php') !== -1 && settings.data instanceof FormData) {
                   if (settings.data.get('form_id') === '602') {
                       var newSettings = syncMethod(settings);
                       return originalAjaxFunction(newSettings)
                           .done(function(response) {
                               if (response.success === true) {
                                   console.log("Successful Login");
                                   // Redirect to the URL in the response
                                   // window.location.href = response.data.redirect_url;
                               } else {
                                   // Handle any custom error message
                                   alert(response.message);
                               }
                           })
                           .fail(function(jqXHR, textStatus, errorThrown) { // Handling failure                
                               // Handle any generic error here
                               console.error("Request failed: " + textStatus, errorThrown);
                               alert("An error occurred. Please try again later.");
                           });
                   }else{
                       return originalAjaxFunction.apply(this, arguments); // Fallback to the original jQuery AJAX function
                   }
               }else{
                   return originalAjaxFunction.apply(this, arguments); // Fallback to the original jQuery AJAX function
               }
           };
       });
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Encrypting Data on Client Side Before Submission](https://wordpress.org/support/topic/encrypting-data-on-client-side-before-submission/)
 *  Thread Starter [netrose](https://wordpress.org/support/users/netrose/)
 * (@netrose)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/encrypting-data-on-client-side-before-submission/#post-17001047)
 * I found that code a few days ago and I’m already using it to turn my text field
   into a password field. What I’m trying to do is encrypt certain field data before
   it gets sent without changing the value of the field itself.

Viewing 2 replies - 1 through 2 (of 2 total)