Created
September 5, 2019 20:01
-
-
Save peiyush13/02db0d1e39f3b5e85cf12e1ca5bae7d0 to your computer and use it in GitHub Desktop.
client side encryption upon form submission
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('form').submit(function( event ) { | |
var encrypt = new JSEncrypt(); | |
$('[data-encrypt]').each(function(){ | |
var unencrypted = $(this); | |
encrypt.setKey($('#public_key').attr('data-value')); | |
var encrypted = encrypt.encrypt(unencrypted.val()); | |
if(encrypted) { | |
unencrypted.val(encrypted); | |
} | |
}) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment