Random number/letter generator

Discussion in 'ASP .Net' started by tshad, May 5, 2005.

  1. tshad

    tshad Guest

    Is there a good random number/letter generator out there?

    I just want to be able to generate a password that has letters and or
    numbers about 10 characters long.

    Thanks,

    Tom
     
    tshad, May 5, 2005
    #1
    1. Advertising

  2. How about System.Random?

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    What You Seek Is What You Get.

    "tshad" <> wrote in message
    news:...
    > Is there a good random number/letter generator out there?
    >
    > I just want to be able to generate a password that has letters and or
    > numbers about 10 characters long.
    >
    > Thanks,
    >
    > Tom
    >
    >
     
    Kevin Spencer, May 6, 2005
    #2
    1. Advertising

  3. tshad

    Brock Allen Guest

    > How about System.Random?

    I don't think this implementation is sufficient for cryptographic purposes.
    Check out System.Security.Cryptography.RandomNumberGenerator and the RNGCryptoServiceProvider
    implementation.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
     
    Brock Allen, May 6, 2005
    #3
  4. tshad

    tshad Guest

    "Brock Allen" <> wrote in message
    news:...
    >> How about System.Random?

    >
    > I don't think this implementation is sufficient for cryptographic
    > purposes. Check out System.Security.Cryptography.RandomNumberGenerator and
    > the RNGCryptoServiceProvider implementation.


    I'll check that out.

    What I came up with temporarily was:

    **********************************************************
    Function RandomNumber(min as Integer, max as Integer) as integer
    Dim random as Random = new Random()
    RandomNumber = random.Next(min, max)
    End Function

    Function RandomString(size as integer, lowerCase as boolean) as string
    Dim builder as StringBuilder = new StringBuilder()
    Dim random as Random = new Random()
    Dim i as integer
    dim ch as char

    for i = 0 to size -1
    ch = Convert.ToChar(Convert.ToInt32(25 * random.NextDouble() + 65))
    random.NextDouble()
    builder.Append(ch)
    next
    if(lowerCase) then RandomString = builder.ToString().ToLower()

    RandomString = builder.ToString()
    end function
    ****************************************************************

    I would then do the following:

    Dim builder as StringBuilder = new StringBuilder()
    builder.Append(RandomString(6, false))
    builder.insert(3,RandomNumber(0, 10))

    password1.text = builder.ToString()

    This seems to do what I want, at least for now.

    Thanks,

    Tom
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
     
    tshad, May 6, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vertigo

    big letter -> small letter

    vertigo, Jul 6, 2004, in forum: Python
    Replies:
    4
    Views:
    762
    Reinhold Birkenfeld
    Jul 6, 2004
  2. Tony Meyer

    RE: big letter -> small letter

    Tony Meyer, Jul 6, 2004, in forum: Python
    Replies:
    0
    Views:
    509
    Tony Meyer
    Jul 6, 2004
  3. Andrew McNamara

    Re: big letter -> small letter

    Andrew McNamara, Jul 6, 2004, in forum: Python
    Replies:
    2
    Views:
    755
    Scott David Daniels
    Jul 6, 2004
  4. globalrev
    Replies:
    4
    Views:
    778
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,185
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page