Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
RAND()om my eyeballs!
Okay I thought I had this neat password generator setup and working fine...until I ran it again the next night and came up with the exact same "ramdom" passwords...in the exact same order as they were generated the night before. That is when I had to go to sleep.
So I have a table of 1650 records with various unique names in it, and a field for the number of times the name has been used.
Char(15), and numeric 1,0
I pick a random number with RAND(). I go to the record number of the random number. So if rand() returned 147, I go to that record. I grab the name. Then I create another random number to add onto the beginning of the name so the suggested password might be 437texas, or 1263humbolt.
In my application I am storing these passwords in a user account table, but mind you I am just testing. So I blow off 20 or 30 passwords, pleased with myself.
The next night I come in again and generate a couple of passwords and I notice they are 'exactly' the same as last night and in the same order!
Here is the code:
<snip>
sele pwnames
*I used 1.6 because I have 1620 records in my names table
lnRandomRec = (RAND() * 1000 ) * 1.6
GO lnRandomRec
DO WHILE PWNames.Cnt > 5
lnRandomRec = (RAND() * 1000 ) * 1.6
GO lnRandomRec
ENDDO
REPLACE PWNames.Cnt WITH PWNames.Cnt + 1
lcPassNumb = TRANSFORM((RAND() *1000),"999")
lcPassName = TRIM(PWNames.Name)
lcPassWord = lcPassNumb + lcPassName
<snip>
I am sure there is a good explaination for this, or I am slipping over the edge.
Terrence
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement