generate random password
Hello!
I need to create strong random password including letters and integers. Does Cache Object Script has methods to generate password or I have to create my own method ?
$ZV: Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2017.2.2 (Build 867_4_20165U) Mon Aug 17 2020 11:28:28 EDT
Hey Token.
You could use ##class(%PopulateUtils).VarString() to generate the random string.
Julian,
I've tested the method above, and depending on a user's needs, it may not be the best fit. I've run it several times, and I've not seen a lower case character and it's really 'heavy' on the punctuation, some of which may not work well with some websites' password requirements. Here's one example:
ZZZ>W ##CLASS(%PopulateUtils).VarString(120) %%XDY^F;="#GO=A<B89&K\ZE&3192R8J+9QFO#7J>M0+W=JW%^CL%BGO.1.W1EJ@7Z3,HS0F(<E?UIAE*+[3"CLD$"'\U
Token,
Years ago I created a password generator utility - it's by no means perfect and it's kind of 'tailored' to my use - I do prefer passwords that alternate left hand then right hand to attempt a bit easier manual typing, and even then the randomization doesn't always create a good 'mix' of characters, so I usually have the utility print 10 passwords (or more) and then I choose the 'best' for character mix, punctuation, etc. The routine could be modified for longer passwords, more/different punctuation characters, etc. It's not the _most_ secure, but it works well for my purposes. Feel free to use/modify it, but use it at your own risk. :-)
To run the utility for one password, just execute this:
W $$^PASSWD
But, I generally just print 10 at a time and choose one. To do that, do the LOTS subroutine (which defaults to 10):
If you want more than 10, add a parameter for the number of passwords you want:
Hope this helps!
Thank you Roger!
I have saved method as generatePass.mac , after executing W $$^PASSWD . I've got error
Token,
If you saved it as generatePass.mac and compiled it, try this to generate a single password:
W $$^generatePass
and if you wanted to generate 20 passwords, you'd call it like this:
D LOTS^generatePass(20)
Hope this helps!
Have a look at this project and this article
Thank you!