passgen function for linux/unix/osx