Generate random password string with Javascript

Generate a random password for a website or javascript application. Include following script to your application and call function randomPassword()

There are various ways to call randomPassword() function within this script. you can test output for this function by calling function with console log.

Default random password with default configuration
console.log(‘Default : ‘, randomPassword());

Password with 32 characters
console.log(‘Default with password length : ‘, randomPassword(32));

Alphabetical password, with 10 characters
console.log(‘Alpha : ‘, randomPassword(10,’alpha’));

Alphabetical password including capital alphabates, with 12 characters
console.log(‘Alpha Caps : ‘, randomPassword(12,’alpha-caps’));

Alphabetical password including numbers, with 8 characters
console.log(‘Alpha Numeric : ‘, randomPassword(8,’alpha-numeric’));

Alphabetical password including capital alphabates and numbers, with 12 characters
console.log(‘Alpha Numeric Caps : ‘, randomPassword(12,’alpha-numeric-caps’));

Alphabetical password including numbers and symbols, with 12 characters
console.log(‘Alpha Numeric Symbols : ‘, randomPassword(12,’alpha-numeric-symbols’));

Alphabetical password including numbers, capital alphabates and symbols, with 12 characters
console.log(‘Alpha Numeric Caps Symbols : ‘, randomPassword(12,’alpha-numeric-caps-symbols’));

Nishant Vaity

Knowledgeable and skilled Technology Lead with an ability of software development and supervision. Possess a Bachelor of Science (BS) in Information Technology along with 10+ years of experience with hands-on coding and team management. By profession, I am a Software Engineer, Technology Mentor & Entrepreneur. Passionate about the technologies I use and always eager to share & learn more from that passion.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: