Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to encrypt in jQuery?

How do I encrypt something in jQuery?
I want to have the option to encrypt via
SHA1 or MD5.

How do I do that?

like image 544
Asaf Avatar asked Aug 15 '10 06:08

Asaf


People also ask

How do I encrypt a URL?

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.

How do you encrypt data in node JS?

// 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);


2 Answers

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 '';
    }
}
like image 132
Mohan Kumar Avatar answered Oct 04 '22 20:10

Mohan Kumar


have list of plugins in this link :

http://www.jquery4u.com/security/10-jquery-security/

example to md5 :

https://github.com/gabrieleromanato/jQuery-MD5

like image 33
Haim Evgi Avatar answered Oct 04 '22 22:10

Haim Evgi