Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Generate random password javascript

const alpha = 'abcdefghijklmnopqrstuvwxyz';
const calpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const num = '1234567890';
const specials = ',.!@#$%^&*';
const options = [alpha, alpha, alpha, calpha, calpha, num, num, specials];
let opt, choose;
let pass = "";
for ( let i = 0; i < 8; i++ ) {
  opt = Math.floor(Math.random() * options.length);
  choose = Math.floor(Math.random() * (options[opt].length));
  pass = pass + options[opt][choose];
  options.splice(opt, 1);
}
console.log(pass);
Comment

random password javascript

 const randomStringMake = (count)=> {
    const letter = "0123456789ABCDEFGHIJabcdefghijklmnopqrstuvwxyzKLMNOPQRSTUVWXYZ0123456789abcdefghiABCDEFGHIJKLMNOPQRST0123456789jklmnopqrstuvwxyz";
    let randomString = "";
    for (let i = 0; i < count; i++) {
        const randomStringNumber = Math.floor(1 + Math.random() * (letter.length - 1));
        randomString += letter.substring(randomStringNumber, randomStringNumber + 1);
    }
    return randomString
}
 
console.log(randomStringMake(10))
Comment

Javascript random password generator 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;
}
Comment

strong random password javascript

Math.random()                        // Generate random number, eg: 0.123456
             .toString(36)           // Convert  to base-36 : "0.4fzyo82mvyr"
                          .slice(-8);// Cut off last 8 characters : "yo82mvyr"
Comment

generate random password javascript

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))), '');
}
Comment

random password generator javascript

let random = Math.floor(Math.random() * 8)
let numorabc = Math.floor(Math.random() * 2)
let random1 = Math.floor(Math.random() * 8)
let random2 = Math.floor(Math.random() * 8)
let random3 = Math.floor(Math.random() * 8)
let random4 = Math.floor(Math.random() * 8)
let random5 = Math.floor(Math.random() * 8)
let random6 = Math.floor(Math.random() * 8)
let random7 = Math.floor(Math.random() * 8)
let lastrandom = Math.floor(Math.random() * 5)



let numbers = ['1','2','3','4','5','6','7','8']
let abc = ['a','b','c','d','e','f','g','p']

let abc1 = abc[random1]
let abc2 = abc[random2]
let abc3 = abc[random3]
let num1 = numbers[random4]
let num2 = numbers[random5]
let num3 = numbers[random6]
let num5 = numbers[random7]

console.log(num3,abc1,num1,abc3,num2,num5)

if(lastrandom = 0){
        console.log(num3,num2,num1,abc1,abc2,abc3)
}else if(lastrandom = 1){
        console.log(abc1,num1,num2,abc2,num5,abc3)
}else if(lastrandom = 2){
        console.log(num1,abc1,num2,abc3,abc2)
}else if(lastrandom = 3){
        console.log(abc1,num1,abc2,num3,abc3,num5)
}else if(lastrandom = 4){
        console.log(abc1,abc2,num2,num3,abc3,num5)
}

Comment

PREVIOUS NEXT
Code Example
Javascript :: how to get the first character of a string in javascript 
Javascript :: jquery if null or empty 
Javascript :: how to convert whole strig in lowercase in js 
Javascript :: wrap text react native 
Javascript :: js get viewport width 
Javascript :: node sleep 
Javascript :: node version not specified in package.json 
Javascript :: roman numeral converter + javascript 
Javascript :: prevent form submit javascript 
Javascript :: on click fade out jquery 
Javascript :: how to assign port in angular 
Javascript :: enter event in jquery 
Javascript :: how to find prime numbers in an array in javascript 
Javascript :: get collection in ascending order firestore 
Javascript :: datepicker on change 
Javascript :: cep validator js 
Javascript :: discord.js kick user 
Javascript :: trim comma in javascript 
Javascript :: break camelcase codewars 
Javascript :: check if is array js 
Javascript :: javascript get body height 
Javascript :: find in highest value key from an object javascript 
Javascript :: check for url change js 
Javascript :: jquery insert element as first child 
Javascript :: onload javascript function call 
Javascript :: how to refresh page on click of button 
Javascript :: remove object from array of objects based on object property javascript 
Javascript :: add attribute selected jquery 
Javascript :: pagecontrol 
Javascript :: get count of div by class 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =