JavaScript losowy generator hasła Exampe

/**
 * Get Auto Generated Random Password
 * 
 * @param   int     length, eg: Default Length = 10
 * 
 * @return  string  Auto generated random password
 */
const getAutoGeneratedPassword = (length = 10) => {
    const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
          genPass = "";

    for (let i = 0, n = charset.length; i < length; ++i) {
        genPass += charset.charAt(Math.floor(Math.random() * n));
    }

    return genPass;
}
Akash