How do I encrypt something in jQuery?
I want to have the option to encrypt via
SHA1 or MD5.
How do I do that?
Under Website security, click Traffic encryption (HTTPS/SSL). Choose when you want to redirect visitors to the secure URL. All http page requests will be redirected to the encrypted https page.
// crypto module const crypto = require("crypto"); const algorithm = "aes-256-cbc"; // generate 16 bytes of random data const initVector = crypto. randomBytes(16); // protected data const message = "This is a secret message"; // secret key generate 32 bytes of random data const Securitykey = crypto. randomBytes(32);
function Encrypt(str) {
if (!str) str = "";
str = (str == "undefined" || str == "null") ? "" : str;
try {
var key = 146;
var pos = 0;
ostr = '';
while (pos < str.length) {
ostr = ostr + String.fromCharCode(str.charCodeAt(pos) ^ key);
pos += 1;
}
return ostr;
} catch (ex) {
return '';
}
}
function Decrypt(str) {
if (!str) str = "";
str = (str == "undefined" || str == "null") ? "" : str;
try {
var key = 146;
var pos = 0;
ostr = '';
while (pos < str.length) {
ostr = ostr + String.fromCharCode(key ^ str.charCodeAt(pos));
pos += 1;
}
return ostr;
} catch (ex) {
return '';
}
}
have list of plugins in this link :
http://www.jquery4u.com/security/10-jquery-security/
example to md5 :
https://github.com/gabrieleromanato/jQuery-MD5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With