vbnet Generate Passwords
Public Function RandomPassword(ByVal Length As Int32) As String Const minLength As Int32 = 8 Const maxLength As Int32 = 32 Dim x As Int32 Dim y As Int32 Dim Password As String = "" If Length = 0 Then Randomize() Length = Int((maxLength * Rnd()) + minLength) If Length > maxLength Then Length = maxLength End If For x = 1 To Length 'Randomize the type of this character y = Int((3 * Rnd()) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase Select Case y Case 1 'Numeric character Randomize() Password = Password & Chr(Int((9 * Rnd()) + 48)) Case 2 'Uppercase character Randomize() Password = Password & Chr(Int((25 * Rnd()) + 65)) Case 3 'Lowercase character Randomize() Password = Password & Chr(Int((25 * Rnd()) + 97)) End Select Next Return Password End Function
Generates a Password for a specified Length. This can be seen in action at beta.slickhouse.com
Updated: Thursday 7th October 2010, 06:56pm
There are 0 comments
Comments are currently closed.