E
E
Evgeny Koryakin2020-08-09 16:36:32
JavaScript
Evgeny Koryakin, 2020-08-09 16:36:32

How to do dropdown with login/password pair and pass password through crypted?

Hello!
There is a form like:

<input id="login">
<input id="pass" type="password">


And a cryptor for it:
var algorithm = 'aes192', password = '1234';
function encrypt(text){
    var cipher = crypt.createCipher(algorithm, password)
    var crypted = cipher.update(text,'utf8','hex')
    crypted += cipher.final('hex');
    return crypted;
}

function decrypt(text){
    var decipher = crypt.createDecipher(algorithm, password)
    var dec = decipher.update(text,'hex','utf8')
    dec += decipher.final('utf8');
    return dec;
}


There are also a couple of commands that interact with the cryptor:
new Builder($("login")).on("oninput", function(){
        window.localStorage['login'] = encrypt(this.value);
    }).on("onblur", updateProfile);
    new Builder($("pass")).on("oninput", function(){
        window.localStorage['pass'] = encrypt(this.value);
    }).on("onblur", updateProfile);

    $("login").value = window.localStorage['login'] ? decrypt(window.localStorage['login']) : "";
    $("pass").value = window.localStorage['pass'] ? decrypt(window.localStorage['pass']) : "";


How to make a dropdown out of all this with a login / password pair and pass the password through crypted?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question