Generating random passwords with Keyboard Maestro

Even though there are a dozen tools and a dozen ways to generate a password, it’s possible to do that very thing using Keyboard Maestro. Why use Keyboard Maestro? Don’t be silly. The answer is obviously, well, why not?

This is a simple macro that uses a dialog to get the length of the password, uses a List (Array) to set up the password, the RAND function to pick a letter, and indexing the List to find characters. It may not be practical, but it’s educational.

I use this for generating test passwords. I test account generation on a regular basis and this makes sure we can handle special character and passwords of a certain length. It automates the process so I don’t have to switch apps, copy, then paste.

Generating a password using Keyboard Maestro. Features a List, Rand, and Repeat.

As you can see from the example, the first step is to prompt for the length of the password. This is stored and used in the Repeat function later on. By default, the length is 15 characters.

Next, we create a List to store all the characters we want to use in the password. This includes upper and lowercase characters, numbers, and multiple symbols. Some systems don’t handle * and ! so adjust accordingly.

After we define the List, we need the length. In Keyboard Maestro using [0] gets the item count – %Variable%instance_myList[0]%. That’s very handy.

To generate the password we use Repeat and Rand.

The Repeat block is called the number of times specified from the user prompt – instance__Password Length

To generate the password, the Rand function is used. A number between 1 and the length of the List is used. RAND(1,instance_listLength)

Once this character is selected, it’s appended to the password string –instance_finalString

After this has been done the correct number of times, the final password is copied to the clipboard.

I’ve tried this quite a few times, and the password is pretty good. Using 15 characters I get results like:

DnEqrNCJ\$gd[)"
@#ES%4/?[q0#Zhp
T?VpnKHY<Q/d7%B

When using KeePassXC, I get results like:
]_.2cQ?fhgL{2*
G*_cH$8]VZJcf'c

Zvps1.xfLSU$D8~

Again, this macro is more an example of Keyboard Maestro features and how it can be used for different tasks. It uses neat features like List, Repeat and Rand. And it was fun to write to see if I could.

Whether you use it for “real” passwords is up to you. Some would argue the seed values and true randomness. That’s not my discussion.

If you want to play along, here are all the characters separated by commas so you don’t have to type them out.

a,b,c,d,e,f,g,h,i,j,kl,m,n,o,p,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,!,@,#,$,%,^,&,*,(,),-,_,=,+,<,>,/,?,',",[,],\,|

Keyboard Maestro Generate Password

Maybe I should've written that in a different font.
Author Signature for Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

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