The HotDocs Computation Archive
Get Extra Help

0137 - Username/Password Generator

Description:

Automatically generates a random network username and password.


• Code •

(UserName-c Computation)

""
RESULT + "«FIRST( Last-t, 4 ):like this»"
RESULT + "«FIRST( First-t, 1 ):like this»"
RESULT + LAST( "«randomNumber-c»", 1 )
RESULT + LAST( "«randomNumber-c»", 1 )
 
 
(Password-c Computation)

""
RESULT + randomLetter-c
RESULT + randomLetter-c
RESULT + randomLetter-c
RESULT + randomLetter-c
RESULT + LAST( "«randomNumber-c»", 1 )
RESULT + LAST( "«randomNumber-c»", 1 )
 
 
(randomNumber-c Computation)

ASK NONE
IF ANSWERED( seed-n ) = FALSE
   DAY OF( TODAY )
ELSE
   seed-n
END IF

POWER( RESULT, 0.33 )

IF RESULT > 4
   RESULT - 4
ELSE IF RESULT > 3
   RESULT - 3
ELSE IF RESULT > 2
   RESULT - 2
ELSE IF RESULT > 1
   RESULT - 1
END IF

RESULT * 100
SET seed-n TO RESULT

TRUNCATE( RESULT, 0 )
ASK DEFAULT
 
 
(randomLetter-c Computation)

SET temp-n TO randomNumber-c

// Numbers 0-49 will be lower-case
IF temp-n < 50
   "«ROUND( temp-n / 2, 0 ) + 1:abc»"

// Numbers 50 and above will be uppercase
ELSE
   "«ROUND( ( temp-n - 50 ) / 2, 0 ) + 1:ABC»"
END IF

• Explanation •

These computations demonstrate how to have HotDocs automatically generate a network user name and/or password. One use is new employee intake forms, where user names and passwords can automatically be generated and assigned.

The default format for network user names is the first four letters of a person's last name, the first letter of the first name, and two random digits (to make the user name less predictable and therefore more secure). So the user name for "Bob Johnson" might be johnb48.

The default format for the password is four random letters (case sensitive) and two random digits: aBcD24 or abCD24.

The formats for both the user name and password are completely customizable within the UserName-c and Password-c computations.

Both the UserName-c and Password-c computations use a behind-the-scenes computation called randomNumber-c. Each time the randomNumber-c computation is called, it returns a random number between 0 and 99. Password-c also uses another computation called randomLetter-c. This computation returns a random letter of the alphabet. Both lower case and upper case letters might be returned.

The randomNumber-c computation is based on Computation #0001: Random Number Generator. A full explanation of its operation is available there.

 

• Model Template •

This template has everything you need set up and configured for you. It will work as-is, or can be adapted to your variable and dialog names. It contains: 1) sample Word and WordPerfect templates (or an Automator form) to demonstrate an implementation of the computation, 2) a component file containing the computation and all supporting dialogs and variables, and 3) instructions for adapting the computation for your use.

(Go to the download page)

 
 

• Contributors •

LegalCS