Random Generation in ASP

Discussion in 'C#' started by hansab, Nov 1, 2008.

  1. #1
    I can generate random numbers in ASP like this 45648794646 but i want something like this adkljaflkj898ad08fafadf

    any idea how can i do it in ASP ?
     
    hansab, Nov 1, 2008 IP
  2. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #2
    asp classic (vbscript/javascript) or asp.net ?
     
    yugolancer, Nov 2, 2008 IP
  3. hansab

    hansab Active Member

    Messages:
    162
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    I wrote ASP. pure ASP. Sorry if wasnt very clear.
     
    hansab, Nov 2, 2008 IP
  4. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #4
    <%
    Function RndPassword(vLength)
      ' generate a random strong password of given length.
      For x=1 To vLength
        Randomize
        vChar = Int(89*Rnd) + 33
        If vChar = 34 Then 'check if it is quote character, replace it with a single quote
          vChar = 39
        End if
        RndPassword = RndPassword & Chr(vChar)
      Next
    End Function
    %>
    Code (markup):
    usage:
    <%
    RndPassword(23)
    %>
    Code (markup):
    I left all non-alphabetical characters too but, you can easily remove them and let only the 1-0 a-z
     
    yugolancer, Nov 2, 2008 IP
  5. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
  6. hansab

    hansab Active Member

    Messages:
    162
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #6
    Thanks alot, i will go through the script and links you provided.
     
    hansab, Nov 2, 2008 IP