Example Code to Generate a Pseudo-Random Password

Less than one minute read time.

A Customer had a need as part of a Case Workflow to generate a Self Service username and password for their contacts. They were using an ASP page to do this and asked whether I had any code to generate a password for Self Service.

This is a simple little script and you may find this useful for your own projects.


function makePassword() 
{
var strPassword = '';
var strChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
for (i=1;i

The usage is very simple


var strMyPassword = makePassword();