vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Tuesday, March 13, 2012

Autogenerate a random password in asp.net


Introduction:
Here we will see about to generate a  password or random character in asp.net.

This type of requirement we need many times, like user create a new login we need to provide random password for the particular user.

In that following case we used this method to generate the random password..
Code:
Function genpassword(ByRef length As Integer)
        Dim passwstr As String
        Dim randnumb As Integer
        Dim intrandom As Random = New Random()
        For i As Integer = 0 To length - 1
            randnumb = intrandom.Next(1, 20)
            passwstr += Microsoft.VisualBasic.Interaction.Choose(randnumb, "A", "1", "D", "2", "F", "3", "G", "4", "H", "5", "J", "6", "K", "7", "L", "8", "M", "9", "N", "P")
        Next
        Return passwstr
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = genpassword(8)
    End Sub

I hope you like this article…..happy coding
Continue your comment relation …………

0 comments:

Post a Comment