Create a Random Password

There are a number of ways to generate useful, random passwords. While these methods will generate variable-length, highly randomized passwords, there is another approach, and quick and dirty approach that requires just a few lines of code!

The Code

<%
    For i = 1 To 7 '7 will be the password length
        Randomize
        j = 1 * Rnd
        j = CInt(j)
        If j = 1 Then
            sPassword = sPassword & Chr(CInt((25 * Rnd) + 65))
        Else
            sPassword = sPassword & CInt(9 * Rnd)
        End If
        For j = 1 To 100
            'slow it down so that randomize has time to re-seed
        Next
    Next
%>

The Result

CNWYKNP
Refresh the page for different results

asp random password password security quick and dirty passwords password generator howto reference examples samples source code


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site