Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

random password generator

function rand_string( $length ) {
	$str = "";
	$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

	$size = strlen( $chars );
	for( $i = 0; $i < $length; $i++ ) {
		$str .= $chars[ rand( 0, $size - 1 ) ];
	}

	return $str;
}
//and call the function this way:
$mypass = rand_string(10);
Comment

make strong random password

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

random password generator

from random import randint

def create_random_chars(charCount):
    return "".join(chr(randint(33,126)) for i in range(charCount))


print(create_random_chars(10))

# Use Source to compile
Comment

generate random password

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

generate random password

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

Generate Password

public string CreatePassword(int length)
{
  const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890<>.,/@#$%^&*()_+!:";
  StringBuilder res = new StringBuilder();
  Random rnd = new Random();
  while (0 < length--)
  {
    res.Append(valid[rnd.Next(valid.Length)]);
  }
  return res.ToString();
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: noty js 
Javascript :: modal multiple images 
Javascript :: async.each javascript 
Javascript :: using server passed values and client js together in ejs 
Javascript :: if array javascript 
Javascript :: loopback 
Javascript :: nextjs sitemap generator 
Javascript :: not .js 
Javascript :: pass a function as a parameter in other function 
Javascript :: Do not use forEach with async-await 
Javascript :: node.js vm 
Javascript :: javascript map method 
Javascript :: repeat pattern regex 
Javascript :: new date javascript 
Javascript :: how to stop angular server 
Javascript :: js number in range 
Javascript :: alpinejs 
Javascript :: Modify String with Uppercase 
Javascript :: how to change textContent in js 
Javascript :: pass props from child to parent 
Javascript :: toggle buttons angular styles 
Javascript :: onclick call function react 
Javascript :: node.js error handling 
Javascript :: expo app.json 
Javascript :: how use multi things in in switch case in js 
Javascript :: javascript validator 
Javascript :: file upload with progress bar 
Javascript :: npm whatsapp api 
Javascript :: javascript problems 
Javascript :: switch statement js 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =