Password Generator

  • 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

  • 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

     

  • Hi,,,

    Try looking on this page http://qa.sqlservercentral.com/scripts/contributions/889.asp

  • 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

  • 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