May 21, 2009 08:21 PM

Random Passwords on Demand

HTA makes it easy to generate random passwords
Rating: (0)
Windows IT Pro
InstantDoc ID #102048
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).

ARTICLE TOOLS

Add a Comment

There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here
Free Power Tools Brochure
Get Mark Minasi's 17-page guide today!



      

advertisement

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS

White Papers

Your remote offices contain valuable electronic data – are they adequately protected? Learn how proven technologies can reliably and cost-effectively back up a branch office from a central location, in real time, to disk or tape, and even utilize existing backup solutions.

Downloads

PacketTrap IT is a comprehensive and affordable network management and application monitoring solution that solves problems associated with bandwidth, network and application performance, and connectivity. Gain insight into your network - try PacketTrapIT free for 21 days!

Web Seminars

IT administrators have to solve a myriad of problems. This web seminar outlines the ten most common systems management pains - including managing highly distributed systems and dealing with data theft/loss – and the best practices to address each.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.