Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


May 21, 2009

Random Passwords on Demand

HTA makes it easy to generate random passwords
RSS
Subscribe to Windows IT Pro | See More Jscript Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

Executive Summary:
Using strong passwords is a necessity nowadays. To create strong passwords, you can use RandPass.hta. This HTML Application provides a simple GUI that lets you generate a list of random passwords in seconds. You can make the passwords as long as needed (up to 128 characters) and as complex as needed (you can use uppercase letters, lowercase letters, numbers, and/or symbols).


It's often useful to be able to generate random passwords for various uses. For example, your backup strategy might require you to use a privileged account that's protected with a long and complex password. To make it easy to generate random passwords, I wrote RandPass.hta, which you can download by clicking the Download the Code Here button at the top of the page. As Figure 1 shows, this HTML Application (HTA) has an easy-to-use GUI.


Figure 1: RandPass.hta's GUI


You just choose the types of characters the random passwords should include, the length of the passwords, and the number of passwords the HTA should generate. When you click the Generate Passwords button, the HTA populates the list box with randomly generated passwords meeting the specified criteria. RandPass.hta can generate up to 128 passwords of up to 128 characters each. The Copy to Clipboard button will copy the entire list to the clipboard. You can also select and copy passwords using a mouse.

By default, RandPass.hta generates random passwords using English uppercase letters, English lowercase letters, and the numbers 0 through 9. You can also select Symbols, which contains the following:

! # $ ' * + , - . / : ; = ? @ [ \ ] _ { } ~

Some symbols (e.g., " < >) have special interpretations when used at a command prompt, so I intentionally skipped them to avoid potential problems. If the list of characters isn't sufficient for your needs, open RandPass.hta in a plain-text editor (such as Notepad) and scroll down to the lines of code shown in Listing 1.


Listing 1: Code That Defines RandPass.hta's Character Classes


Modify the characters between the double quotes and save the file. Note that the backslash (\) is doubled because the backslash is JScript's escape character. Also, if you want to include the double quote (") in the Symbols set, you must escape it with a backslash (i.e., \") to avoid a syntax error.

Inside the HTA
The most interesting part of RandPass.hta is the code that makes it work. Like any HTA, RandPass.hta consists of HTML tags and code that responds to events. Table 1 lists the HTML tags that correspond to the application's GUI elements.


Table 1: RandPass.hta's GUI Elements and Associated HTML Markup
GUI Element HTML Markup
Check boxes <input type="checkbox" ... />
Input boxes <input type="text" ... />
Submit button <input type="submit" ... />
Text area <textarea> ... </textarea>
Standard buttons <input type="button" ... />

RandPass.hta uses four check boxes (for the character classes), two input boxes (for the Password length and Number of passwords fields), a submit button (for the Generate Passwords button), a text area (for the list of passwords), and three standard buttons (for the Copy to Clipboard, Clear List, and Close buttons).

   Previous  [1]  2  3  Next 


Top Viewed ArticlesView all articles
WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

Understanding File-Size Limits on NTFS and FAT

A general confusion about files sizes on FAT seems to stem from FAT32's file-size limit of 4GB and partition-size limit of 2TB. ...


Related Articles HTA Automatically Creates Mappings

5 Tips to Ensure Safe Passwords

Turn Digital Objects Into Passwords

HTA F/X

Security Whitepapers Reducing the Costs and Risks of Branch Office Data Protection

Solving Desktop Management Challenges in Healthcare

Solving Desktop Management Challenges in Education

Related Events WinConnections and Microsoft® Exchange Connections

Deep Dive into Windows Server 2008 R2 presented by John Savill

Introduction to Identity Lifecycle Manager "2"

Check out our list of Free Email Newsletters!

Security eBooks Spam Fighting and Email Security for the 21st Century

Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

Related Security Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement