“menghasilkan kata sandi yang kuat” Kode Jawaban

menghasilkan kata sandi acak

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

menghasilkan kata sandi acak

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

menghasilkan kata sandi yang kuat

# 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

Jawaban yang mirip dengan “menghasilkan kata sandi yang kuat”

Pertanyaan yang mirip dengan “menghasilkan kata sandi yang kuat”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya