Answers for "generate password js"

2

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))
Posted by: Guest on July-05-2021
2

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);
Posted by: Guest on July-30-2021
5

javascript password generator example

function generatePassword(passwordLength) {
  var numberChars = "0123456789";
  var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var lowerChars = "abcdefghijklmnopqrstuvwxyz";
  var allChars = numberChars + upperChars + lowerChars;
  var randPasswordArray = Array(passwordLength);
  randPasswordArray[0] = numberChars;
  randPasswordArray[1] = upperChars;
  randPasswordArray[2] = lowerChars;
  randPasswordArray = randPasswordArray.fill(allChars, 3);
  return shuffleArray(randPasswordArray.map(function(x) { return x[Math.floor(Math.random() * x.length)] })).join('');
}

function shuffleArray(array) {
  for (var i = array.length - 1; i > 0; i--) {
    var j = Math.floor(Math.random() * (i + 1));
    var temp = array[i];
    array[i] = array[j];
    array[j] = temp;
  }
  return array;
}

alert(generatePassword(12));
Posted by: Guest on January-14-2020
5

javascript password generator

var Password = {
 
  _pattern : /[a-zA-Z0-9_\-\+\.]/,
  
  
  _getRandomByte : function()
  {
    // http://caniuse.com/#feat=getrandomvalues
    if(window.crypto && window.crypto.getRandomValues) 
    {
      var result = new Uint8Array(1);
      window.crypto.getRandomValues(result);
      return result[0];
    }
    else if(window.msCrypto && window.msCrypto.getRandomValues) 
    {
      var result = new Uint8Array(1);
      window.msCrypto.getRandomValues(result);
      return result[0];
    }
    else
    {
      return Math.floor(Math.random() * 256);
    }
  },
  
  generate : function(length)
  {
    return Array.apply(null, {'length': length})
      .map(function()
      {
        var result;
        while(true) 
        {
          result = String.fromCharCode(this._getRandomByte());
          if(this._pattern.test(result))
          {
            return result;
          }
        }        
      }, this)
      .join('');  
  }    
    
};
Posted by: Guest on July-26-2020
0

javascript password generator

function getpass() {
    var chars = "0123456789~!@#$%^&*()_+}{[]|abcdefghikjlmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var pass = "";
    var passLength = 16;
    for (var i = 0; i < passLength; i++) {
        var randPass = Math.floor(Math.random() * chars.length);
        pass += chars.substring(randPass, randPass+1);
    }
    document.getElementById('strong_pass').value = pass;
}
function copyToClipboard() {
    var copyText = document.getElementById('strong_pass');
    var copyPass = document.getElementById('strong_pass').value;
    var fa_iocn = document.getElementsByClassName('fa');
    if (copyPass == "") {
        alert("Please Generate Password");
    }else {
        $(fa_iocn).removeClass("fa-copy");
        $(fa_iocn).addClass("fa-check");
        $("#strong_pass").addClass("focus_success");
        alert("Password Copied Successfully")
    }
    copyText.select();
    copyText.setSelectionRange(0, 99999);
    document.execCommand("copy");
}
$(".strong_pass_generator #generatorbutton").click(function(){
    $(".strong_pass_generator i").removeClass("fa-check");
    $(".strong_pass_generator i").addClass("fa-copy");
});
Posted by: Guest on September-19-2021
-2

javascript password generator

<input type='text' id='p'/><br/>
<input type='button' value ='generate' onclick='document.getElementById("p").value = Password.generate(16)'>
Posted by: Guest on July-26-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language