Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generating a password with only alpha characters and dig
Message
From
22/04/2008 09:51:56
 
General information
Forum:
ASP.NET
Category:
Security
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01312284
Message ID:
01312335
Views:
14
>give a try to this one:
>
>    Private Function GeneratePassword(ByVal passwordLength As Integer) As String
>        Dim Vowels() As Char = New Char() {"a", "e", "i", "o", "u"}
>        Dim Consonants() As Char = New Char() {"b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v"}
>        Dim DoubleConsonants() As Char = New Char() {"c", "d", "f", "g", "l", "m", "n", "p", "r", "s", "t"}
>        Dim wroteConsonant As Boolean  'boolean
>        Dim rnd As New Random
>        Dim passwordBuffer As New System.Text.StringBuilder
>        wroteConsonant = False
>
>        For counter As Integer = 0 To passwordLength
>            If passwordBuffer.Length > 0 AndAlso (wroteConsonant = False) AndAlso (rnd.Next(100) < 10) Then
>                passwordBuffer.Append(DoubleConsonants(rnd.Next(DoubleConsonants.Length)), 2)
>                counter += 1
>                wroteConsonant = True
>            Else
>                If (wroteConsonant = False) AndAlso (rnd.Next(100) < 90) Then
>                    passwordBuffer.Append(Consonants(rnd.Next(Consonants.Length)))
>                    wroteConsonant = True
>                Else
>                    passwordBuffer.Append(Vowels(rnd.Next(Vowels.Length)))
>                    wroteConsonant = False
>                End If
>            End If
>        Next
>        'size the buffer
>        passwordBuffer.Length = passwordLength
>        Return passwordBuffer.ToString
>    End Function
>
Thanks
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform