My first applescript studio app
Fri 16 January 2004 by Kevin van HaarenI wrote my first Applescript Studio. It’s a simple password generator but I think it’s pretty cool. If you have Mac OS X 10.2 or greater you can click here to download. I wrote with Apple’s XCode so the source may only be viewable on 10.3.
Applescript stuido is pretty neat. An admirable competitor to Visual Basic, with the huge benefit of being free (as in beer). The language scans funny if you’ve written in other languages, but it reads pretty well as english.
Here’s the core routine that generates a password. PassLen is the length of the password to create, ValidChars is a list of characters that can be use, MaxRepeats is the maximum times one character can appear in a password.
on GenPassword(PassLen, ValidChars, MaxRepeats)
set Passwd to ""
repeat PassLen times
set PassChar to some item of ValidChars as string
repeat while CountChar(PassChar, Passwd) ≥ MaxRepeats
set PassChar to some item of ValidChars as string
end repeat
set Passwd to Passwd & PassChar
end repeat
return Passwd
end GenPassword