login.js
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
if (typeof(dmap) == "undefined") var dmap = {};
dmap.login = {
init: function() {
$('#btn-login').bind('click', function(e) {
let username = $("#username").val();
let password = $("#password").val();
// if (username.length <= 0 || password.length <= 0) {
// tips.notify("用户名或密码不能为空", "danger", 1e3);
// return false;
// }
let aesKey = JsCrypto.Utf8.parse('w03MyIgc3zMHM5Qe'),
iv = JsCrypto.Utf8.parse('8765432187654321'),
instr = JsCrypto.Utf8.parse(password);
let encryptData = JsCrypto.AES.encrypt(instr, aesKey, {
iv: iv,
mode: JsCrypto.mode.CBC,
padding: JsCrypto.pad.Pkcs7
});
let crypt_pwd = encryptData.cipherText.toString();
let form = document.createElement('form');
form.method = 'post';
createElement(form, { username: username, password: crypt_pwd });
form.style.display = "contents";
document.body.appendChild(form);
form.submit();
});
function createElement(form, params) {
for (const key in params) {
if (params.hasOwnProperty(key)) {
const hiddenField = document.createElement('input');
hiddenField.type = 'hidden';
hiddenField.name = key;
hiddenField.value = params[key];
form.appendChild(hiddenField);
}
}
}
}
};