To make it even cleaner, instead of injecting records into mdl_user table yourself, you may better want to use the web services and call the core_user_create_users
function from your app.
General developer forum
Password generator
This discussion has been locked so you can no longer reply to it.