How-to Generate Complex Passwords?

Hi Everyone!

I need to generate random passwords with random lengths (5-80 characters) with the following properties:

  • Minimum of 1 lowercase letter [a-z]
  • Minimum of 1 uppercase letter [A-Z]
  • Minimum of 1 numeric character [0-9]
  • Minimum of 1 special character: ~`!@#$%^&*()-_+={}|;:"<>,./?

Unfornatually, the Faker Dynamic Variable $randomPassword (A random 15-character alpha-numeric password) does not provide the flexibility I require!

I tried using an old CDN, but I got the following error "There was an error in evaluating the Pre-request Script:Error: Maximum call stack size exceeded"

window = {};
pm.sendRequest(โ€œโ€, (error, response) => {
if (error || response.code !== 200) {โ€˜Could not load external libraryโ€™);


const randomPasswordLength = _.random(5, 80);

pm.environment.set("randomPassword", window.faker.internet.password(randomPasswordLength, false, /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]/));


I do not think I am the first one trying to generate complex passwords. Do you use other CDN or code the required functions in the Pre-request Scripts?

Looking forward to hearing from the postman crew :slight_smile:

I guess I found an easy/fast approach API - Make Me a Password :slight_smile:


Relying on a third-party API to generate your passwords for you seems excessive.

What happens if that API is down?

Postman uses JavaScript under the hood, so you just need search for one.

A quick search and looking at one of the first results.

javascript password generator - Stack Overflow

There are a few options in that link.

This snippet looks good enough for your requirement.

const Allowed = {
    Lowers: "qwertyuiopasdfghjklzxcvbnm",
    Numbers: "1234567890",
    Symbols: "!@#$%^&*"

const getRandomCharFromString = (str) => str.charAt(Math.floor(Math.random() * str.length))
const generatePassword = (length = 8) => { // password will be @Param-length, default to 8, and have at least one upper, one lower, one number and one symbol
    let pwd = "";
    pwd += getRandomCharFromString(Allowed.Uppers); //pwd will have at least one upper
    pwd += getRandomCharFromString(Allowed.Lowers); //pwd will have at least one lower
    pwd += getRandomCharFromString(Allowed.Numbers); //pwd will have at least one number
    pwd += getRandomCharFromString(Allowed.Symbols);//pwd will have at least one symbolo
    for (let i = pwd.length; i < length; i++)
        pwd += getRandomCharFromString(Object.values(Allowed).join('')); //fill the rest of the pwd with random characters
    return pwd

here you can check for how can i generate password using single click
using jquery you can made it your ownpassword generator