12 digit random password generator7/18/2023 Set lowercaseLetters to makeRandom(lowercaseLetters, lowercaseLetterCount) Set lowercaseLetters to "abcdefghijklmnopqrstuvwxyz" If passwordLength mod 2 ≠ 0 then set uppercaseLetterCount to uppercaseLetterCount + 1 Set lowercaseLetterCount to (passwordLength - (nonLetterCount * 2)) div 2Ĭopy lowercaseLetterCount to uppercaseLetterCount If passwordLength mod 12 = 0 then set nonLetterCount to nonLetterCount - 1 Set nonLetterCount to (passwordLength div 12) + 1 - modify as desired The script takes 3 milliseconds on my computer to generate a 24-character password. The password is not random in that it includes a specific number of lowercase and uppercase letters, numbers, and special characters. I’ve included a suggestion below which meets the above requirement. (display dialog "Password Rules" & r & r & "All passwords must have at least 12 characters, so how many characters would you like?" default answer "12")ĭisplay dialog "The text entered must be a number!" If (button returned of the result is "Not Now") then error number -128 -"User canceled" The code here both displays it and returns it: set r to returnĭisplay dialog "Random Password generator" & r & r & "A small application to quickly and easily generated random secure passwords" buttons ¬ I don’t know what you want to do with the password once it’s created. Here’s your script rearranged into working order. Plus how do I get the result to display in a box with the buttons I mention above (copy password and quit, copy and generate another password, quit.)īut there’s something screwy now because I’m not sure it’s actually generating a password. Set numberOfCharacters to numberOfCharacters as integerĭisplay dialog “The text entered must be a number!”īut there’s something screwy now because I’m not sure it’s actually generating a password. ( display dialog “Password Rules” & r & r & “All passwords must have at least 12 characters, so how many characters would you like?” default answer “12”) Set numberOfCharacters to text returned of ¬ If (button returned of the result is “Not Now”) then error number -128 – “User canceled” So the script now looks like this (couldn’t work out how to get the AppleScript thing to work in the post, sorry)ĭisplay dialog “Random Password generator” & r & r & “A small application to quickly and easily generated random secure passwords” buttons ¬ … but the setting the numbers and characters bit is really throwing me. I really do genuinely appreciate it.” buttons ¬ I’m fairly certain I know how to get the dialogue boxes to appear because I’ve done scripts with these in them before …ĭisplay dialog “Thanks for your donation. When they hit this button it needs to take them through to a further dialogue box showing the password and three buttons - copy password and quit, copy and generate another password, quit. I want to set the number of numbers and special characters into the password to something like one of each for a 12 character password, 2 of each for 13-23 character passwords, 3 of each for 24-34 character passwords and 4 of each for any password that has 35-50 characters. When people run the script ideally I want to make initially open up a dialogue box giving users the ability to set the password length (with a 12 character default minimum) and a button say something like, “Generate”. Set thePassword to thePassword & randomCharacter Set randomCharacter to some character of theCharacters I’m trying to write a fairly simple script (to be turned into an app) to generate random passwords for a NGO that I’m working with. I’m a bit of a rookie when it comes to AppleScript and I could do with a hand, if anyone can help please?
0 Comments
Leave a Reply. |