“gerar senha forte” Respostas de código

gerar senha aleatória

var btn = document.getElementById("btn");

btn.addEventListener("click", function generate() {
  var generatePassword = "";
  var password = document.getElementById("password");
  var characters =
    "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*?";

  for (var i = 0; i < 10; i++) {
    generatePassword += characters.charAt(
      Math.floor(Math.random() * characters.length)
    );
  }
  password.innerHTML = generatePassword;
});
Nitria

gerar senha aleatória

const generatePassword = (length = 10, specialChars = true) => {
    const alphaCodesArray = Array.from(Array(26)).map((e, i) => i + 65);
    const uppercaseAlphabetArray = alphaCodesArray.map((letterCode) => String.fromCharCode(letterCode));
    const lowercaseAlphabetArray = uppercaseAlphabetArray.map(e => e.toLowerCase());

    const uppercaseAlphabet = [...uppercaseAlphabetArray].join('');
    const lowercaseAlphabet = [...lowercaseAlphabetArray].join(''); 
    const numbers = [...Array(10).keys()].join('');
    const specialSymbols = typeof specialChars === 'string' ? specialChars : (specialChars ? "!@#$%^&*?" : "");
    
    const characters = `${lowercaseAlphabet}${numbers}${uppercaseAlphabet}${specialSymbols}`;

    return [...Array(length).keys()].reduce(acc => acc.concat(characters.charAt(Math.floor(Math.random() * characters.length))), '');
}
nilso

gerar senha forte

# Generate strong password
import random
import string


def generate_password(length):
    """
    Generate strong password with length

    Args:
        length (int): length of password

    Returns:
        password (str): strong password
    """
    password = ''
    for i in range(length):
        password += random.choice(string.ascii_letters + string.digits)
    return password


def main():
    length = int(6)  # length of password
    password = generate_password(length)
    print(password)


if __name__ == '__main__':
    main()
Ugly Unicorn

Respostas semelhantes a “gerar senha forte”

Perguntas semelhantes a “gerar senha forte”

Procure respostas de código populares por idioma

Procurar outros idiomas de código