October 20, 2004 at 8:50 am
Hey guys,
Question for anyone that can help. My company just put out a new website earlier this week. Everything is working great, but there are still a few things that need cleaned up.
Question is: I'm wanting to create a password generator for those people who have lost/forgotten their password based on their email address and the answer to their secret question.
Does anyone know how to generate a randomly generated password using SQL? Or ASP for that matter?
Any help would be greatly appreciated
October 20, 2004 at 9:09 am
From SQL
SELECT NEWID()
You can use RAND() function but I don't like converting the number to varchar so I'd use A globally unique identifier (GUID).
There are may other ways but this one, I use
October 21, 2004 at 2:17 am
Hi,,,
Try looking on this page http://www.sqlservercentral.com/scripts/contributions/889.asp
October 21, 2004 at 7:19 am
Hi,
a quick hack is:
declare @pwd sysname;
declare @pwd1 sysname;
select @pwd1=str(rand(datename(ms,getdate()))*1000000000);
select @pwd=substring(@pwd1,4,len(@pwd1));
It generates quasi random strings containing 7 numbers.
Karl
Best regards
karl
October 21, 2004 at 9:18 am
here is a function i use on an asp page
it would be called by using something like this:
sRegNum = RandomPW(8)
Function RandomPW(myLength)
'These constant are the minimum and maximum length for random
'length passwords. Adjust these values to your needs.
Const minLength = 6
Const maxLength = 20
Dim X, Y, strPW
If myLength = 0 Then
Randomize
myLength = Int((maxLength * Rnd) + minLength)
End If
For X = 1 To myLength
'Randomize the type of this character
Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase
Select Case Y
Case 1
'Numeric character
Randomize
strPW = strPW & CHR(Int((9 * Rnd) + 48))
Case 2
'Uppercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 65))
Case 3
'Lowercase character
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 97))
End Select
Next
RandomPW = LCase(strPW)
End Function
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply