1function CreatePassword(PassLenght) {
2 const Lenght = parseInt(PassLenght)
3 const Charecters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
4 let Password = "";
5 for (var i = 0, n = Charecters.length; i < Lenght; ++i) { Password += Charecters.charAt(Math.floor(Math.random() * n)); }
6 console.log(Password)
7 return Password;
8}
9
10CreatePassword(18)
1function getpass() {
2 var chars = "0123456789~!@#$%^&*()_+}{[]|abcdefghikjlmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
3 var pass = "";
4 var passLength = 16;
5
6 for (var i = 0; i < passLength; i++) {
7 var randPass = Math.floor(Math.random() * chars.length);
8 pass += chars.substring(randPass, randPass+1);
9 }
10 document.getElementById('strong_pass').value = pass;
11}
12
13function copyToClipboard() {
14 var copyText = document.getElementById('strong_pass');
15 var copyPass = document.getElementById('strong_pass').value;
16 var fa_iocn = document.getElementsByClassName('fa');
17
18 if (copyPass == "") {
19 alert("Please Generate Password");
20 }else {
21 $(fa_iocn).removeClass("fa-copy");
22 $(fa_iocn).addClass("fa-check");
23 $("#strong_pass").addClass("focus_success");
24 alert("Password Copied Successfully")
25 }
26 copyText.select();
27 copyText.setSelectionRange(0, 99999);
28 document.execCommand("copy");
29}
30
31$(".strong_pass_generator #generatorbutton").click(function(){
32 $(".strong_pass_generator i").removeClass("fa-check");
33 $(".strong_pass_generator i").addClass("fa-copy");
34});
1var btn = document.getElementById("btn");
2
3btn.addEventListener("click", function generate() {
4 var generatePassword = "";
5 var password = document.getElementById("password");
6 var characters =
7 "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*?";
8
9 for (var i = 0; i < 10; i++) {
10 generatePassword += characters.charAt(
11 Math.floor(Math.random() * characters.length)
12 );
13 }
14 password.innerHTML = generatePassword;
15});
16
1// Password generator
2#include <iostream>
3#include <string>
4#include <algorithm>
5#include <sstream>
6
7std::string password_gen() {
8 std::string result;
9 while (!any_of(result.begin(), result.end(), ::islower) ||
10 !any_of(result.begin(), result.end(), ::isupper) ||
11 !any_of(result.begin(), result.end(), ::isdigit)) {
12 std::stringstream ss;
13 int length = rand() % 15 + 6;
14 for (int i = 0; i < length; i++) {
15 unsigned randomChar = rand() % 62;
16 if (randomChar < 26)
17 ss << char(randomChar + 'a');
18 else if (randomChar < 52)
19 ss << char(randomChar - 26 + 'A');
20 else if (randomChar < 62)
21 ss << char(randomChar - 52 + '0');
22 result = ss.str();
23 }
24 }
25 return result;
26}
27
28using namespace std;
29
30int main() {
31
32 cout<<"New random password = " << password_gen();
33}
1import string
2from random import *
3
4characters = string.ascii_letters + string.digits
5Password = "".join(choice(characters) for x in range(randint(8, 16)))
6print(Password)