Formula to generate random passwords using numbers, upper and lower case and special characters

I am looking for a formula that I can link to a button to generate random passwords that fit the following; 12 characters, upper and lower case, numbers and special characters. I have found a few excel ones but they are very limited and will not do much. I am hoping someone has done this before. Thanks for any help!

1 Like

Most definitely!

@Jono_Bouwmeester could probably give you some great direction

Dear @Terry_Stagg,

I never challenged myself to build a password generator in Coda, mainly because it’s not intended to fulfill such a task for various reasons, while Coda has strengths in many other areas as advertised.

For a password generator / storage, I am using and can recommend the open source https://bitwarden.com/

The code is public available available, audited on a regular basis to keep up the standard and security.

Other tools are LastPass, keeper, dashlane and with some research you will find a ton of offers that might suit you.

Keep building with Coda :building_construction::1st_place_medal:

Thanks for the comment. I should have provided some more context. I am wanting to use this to assign users their passwords meeting the criteria I set. Currently I have a solution for this that works perfectly and I have generated over 200 using that but since I use coda for most things and I was wanting to make a button to generate it without having to go to a separate workspace. I work in coda almost all day and if I can do it with coda, I try to. Thanks again for the response.

Thank you @Scott_Collier-Weir i will check out his page and see what I can find.

Hi gents, sorry for the late reply!

@Terry_Stagg , I do have some code I’ve used recently for my new doc (Encryption in Coda: Can you keep a secret?)

It’s really efficient, and will generate a ton of passwords quickly, however they may not necessarily meet your requirements every time so you’ll need to built in some way to validate the output before acceptance (I’ve got a second solution further down which will meet your requirements)

Split("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-=+", "")
  .RandomSample(12, False(), True())
    .Join("")

How this works…

  1. Passing a blank string ("") to the Split() formula takes the string of characters and breaks them up into an array of individual characters.
  2. Next we pass that array to RandomSample() which is a formula which picks a set number of random items out of whatever array you pass it. In this case we request 12 items.
  3. Finally, we Join() the randomly picked characters together. The empty string means that the characters are glued together without any delimiter.

The False() and True() arguments for RandomSample() are options for withReplacement and updateContinuously (respectively).

withReplacement set to false means that characters are not allowed to potentially repeat in the random sample. If you’re ok with having a letter potentially repeat in the output, set this to true.
updateContinuously will generate new random samples whenever the doc loads, so you’re more likely to get unique results. Note however, you’ll need to STORE the output, otherwise your users passwords will change each time the doc is loaded!

If you wanted to generate these using a button, then the formula for the button would be something like:

thisRow.ModifyRows(
  thisRow.Password, 
  Split("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-=+_", "")
  .RandomSample(12, False, True)
  .Join("")
)

If you wanted to ENSURE upper/lower/special in ALL outputs, a solution could be to repeat the above code 3 times with separate strings passed for the three character categories, then join the whole bunch together. I’ve built a doc to show you both solutions.

Hope that helps!

5 Likes

@Jono_Bouwmeester

once again an excellent approach and a great explanation

well done

max

2 Likes

as @Xyzor_Max said, very well done @Jono_Bouwmeester!

3 Likes

Thanks gents :slight_smile: Learned so much from that last doc, it’s fun to have some code handy that can help other people. Lord knows I’ve stolen code from both @Christiaan_Huizer and @Xyzor_Max more times than I can count haha

3 Likes

This is amazing! Exactly what I was needing. Thank you so much for sharing this great information. It worked perfectly and allowed me to make the passwords I needed without having to go to a separate site.

Thanks again!

3 Likes

Ah that’s fantastic. So glad it was useful to you @Terry_Stagg.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.