Wrap password generation in a function

Allows more flexibility, for say, programatic password generation from other python scripts, or command-line arguments.