Temporary Password Generation

I am working on registration for a system where it generates a password and then emails to the person registering. Here is the method I used to come up with short, unique and somewhat complex passwords.

I did it in php, but you can use the algorithm in any language.

<?php

function generate_password() {
    return substr(md5(time() . rand()), rand(0, 24), 8);
}

?>

It takes a random eight character slice of an MD5 of the time plus a pseudo-random integer, which will give you an alphanumeric string. It is a short but complex enough of a password to give someone until they can change it to whatever they want. I thought this was pretty clever, so I wanted to share it here.

Leave a Reply

{
}