1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 23:48:47 +00:00

Merge pull request #5020 from haiwen/random-password

update utils.js
This commit is contained in:
Daniel Pan
2021-11-05 17:46:44 +08:00
committed by GitHub

View File

@@ -1304,12 +1304,34 @@ export const Utils = {
}
},
generatePassword: function(passwordLength) {
let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789';
let password = '';
for (let i = 0; i < passwordLength; i++) {
password += possible.charAt(Math.floor(Math.random() * possible.length));
generatePassword: function(length, hasNum=1, hasChar=1, hasSymbol=1) {
var password = "";
// 65~90A~Z
password += String.fromCharCode(Math.floor((Math.random() * (90-65)) + 65));
// 97~122a~z
password += String.fromCharCode(Math.floor((Math.random() * (122-97)) + 97));
// 48~570~9
password += String.fromCharCode(Math.floor((Math.random() * (57-48)) + 48));
// 33~47!~/
password += String.fromCharCode(Math.floor((Math.random() * (47-33)) + 33));
// 33~47!~/
// 48~570~9
// 58~64:~@
// 65~90A~Z
// 91~96[~`
// 97~122a~z
// 123~127{~
for (var i = 0; i <= length-4; i++) {
var num = Math.floor((Math.random() * (127-33)) + 33);
password += String.fromCharCode(num);
}
return password;
},
@@ -1502,7 +1524,7 @@ export const Utils = {
onKeyDown: function(e) {
if (e.key == 'Enter' || e.key == 'Space') {
e.target.click();
}
}
}
};