Skip to content

Instantly share code, notes, and snippets.

@epetousis
Created November 22, 2011 05:20
Show Gist options
  • Save epetousis/1384963 to your computer and use it in GitHub Desktop.
Save epetousis/1384963 to your computer and use it in GitHub Desktop.
A AppleScript to generate a password.
repeat
set passwrd to {}
display dialog "How many characters do you want this password to have? NOTE: Don't enter anything other than a number." default answer "64" buttons {"This amount"}
set char_amnt to text returned of result
repeat (char_amnt) times
set end of passwrd to some item of "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
end repeat
display dialog "Your password is:" default answer passwrd as string buttons {"Copy to clipboard and quit", "Another one"}
set the_button to button returned of result
if the_button is "Copy to clipboard and quit" then
tell application "Finder" to set the clipboard to passwrd as text
error number -128
end if
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment