-
Notifications
You must be signed in to change notification settings - Fork 53
Script: GeneratePassword
Samuel Plentz edited this page Jun 6, 2023
·
2 revisions
Generate a random password.
Scriptname: GeneratePassword
var password_length = 20;
var password_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.!?,;:-~+*=_/()[]{}#$@&%|'" + /* the chars '\' and '"' need to be escaped */ "\\\"";
var password = '';
if(mVariables.length >= 1) password_length = mVariables[0];
if(mVariables.length >= 2) password_chars = mVariables[1];
for(var i = 0; i < password_length; i++) {
var position = Math.floor(Math.random() * password_chars.length);
password += password_chars.substring(position, position + 1);
}
return "Password: " + password + "\n";
Generate a password with a length of 20 characters, containing numbers, uppercase letters, lowercase letters and special characters:
[[SCRIPT=GeneratePassword]]
Example output: Password: Uz4]V6IRWYSO/*wCqiVR
Generate a password with a length of 10 characters, containing numbers, uppercase letters, lowercase letters and special characters:
[[SCRIPT=GeneratePassword|10]]
Example output: Password: Hruck)q![f
Generate a password with a length of 6 characters, containing numbers only:
[[SCRIPT=GeneratePassword|6|0123456789]]
Example output: Password: 902217