Re: Generating random values.

Поиск
Список
Период
Сортировка
От Mike Nolan
Тема Re: Generating random values.
Дата
Msg-id 200508171735.j7HHZcI7026929@gw.tssi.com
обсуждение исходный текст
Ответ на Generating random values.  (Fernando Lujan <flujan@gmail.com>)
Список pgsql-general
> I have a table wich contains my users... I want to insert to each user
> a random password, so I need a random function. Is there such function
> in Postgres? I just found the RANDOM which generates values between
> 0.0 and 1.0.

If you multiply that random number by a large integer and then truncate
or round the result, you will get a random integer between 0 and
whatever you use as a multiplier.

For example, 'select round(random() * 999999)' will generate a six digit
random integer.

Whether that's a good password generator is a completely different subject,
one for which there is no 'best' answer.

The more arbitrary the password, the more likely the user is to write it
down or have it saved in a password file on their computer, both of which
tend to defeat the purpose of having passwords in the first place.

I find some rather silly password 'standards' out there.  For example,
one company I've done business with requires that their passwords be
EXACTLY six characters long, of which two must be UPPER CASE letters,
two must be lower case letters and two must be numbers.

I have a short PHP program which generates (IMHO) better random passwords,
using several random numbers to select two short words (2-4 characters)
from a dictionary file and adding in a number.

Here are a few passwords generated by it just now:

caps270nods
egopegs326
mast659quip
semi607it
rots505hot

I usually generate 3 or 4 passwords then let the user pick one.  I often
screen the output so that I don't get passwords like this one:

pissbum560
--
Mike Nolan

В списке pgsql-general по дате отправления:

Предыдущее
От: eu
Дата:
Сообщение: PostgreSQL 8.0.3 limiting max_connections to 64 ?
Следующее
От: Greg Stark
Дата:
Сообщение: Re: table clustering brings joy