Photo of the Day

aurora1.jpg
The ALBUMS section is full of stuff! Here's today's pick!

download photo

See more photos

Todd's Blog Return to catagory list

 

Password generator....without the frills!!!
Article Number: 59 Date Added: 05/10/2008 04:06:56
Total Views: 614 Average rating: 10.0 Total Rating: 10

Passwords!!!

I'm amazed at how many people use the word "password"!! Or even better, their name!! If you are one of these people..your an idiot!! If not...read on..

I was once told that passwords are the most important part of the system. NOT TRUE!!!

Preventing a user from SETTING THEIR OWN PASSWORD is the most important part!!!

But you don't want to make it too complex for them. They are, after all, mostly lemming types!!

So.....try this on...

Public Shared Function GeneratePassword(ByVal pwdlength As Integer) As String

Randomize()

Dim RndSel As Integer = 0
Dim intI As Integer = 0
Dim tmp As Integer = 0
Dim _Assembled_Password As String = String.Empty

For intI = 1 To pwdlength

'randomly select which character groups to use
' 0 = numbers (1-9)
' 1 = UPPER case letters (A-Z)
' 2 = lower case letters (a-z)

RndSel = CInt(3 * Rnd())

Select Case RndSel

Case 0

'Get a random number corresponding to ascii character
'sets 49 - 57 (numeric 1 thru 9)

tmp = CInt(8 * Rnd()) + 49

Do While tmp < 49 Or tmp > 57

tmp = CInt(8 * Rnd()) + 49

Loop

Case 1

'Get a random number corresponding to ascii character
'sets 65 - 90 (Alpha UPPER-case, EXCLUDING the
'letters I (int value of 73) and O (int value of 79))

tmp = CInt(26 * Rnd()) + 65

Do While tmp = 73 Or tmp = 79 Or tmp < 65 Or tmp > 90

tmp = CInt(26 * Rnd()) + 65

Loop

 

Case Else

'Get a random number corresponding to ascii character
'sets 97 - 122 (Alpha lower-case, EXCLUDING the
'letters I (int value of 105) and O (int value of 111))

tmp = CInt(26 * Rnd()) + 97

Do While tmp = 105 Or tmp = 111 Or tmp < 97 Or tmp > 122

tmp = CInt(26 * Rnd()) + 97

Loop

End Select

_Assembled_Password &= Chr(tmp)

Next

Return _Assembled_Password

End Function

Implementation is simple. Call "GeneratePassword" and give it a length. It returns said length in alpha-numeric, UPPER and lower case!

This code is 6 years old, and I still use it

Oldie but goodie!

:)

 

Rate This Article:



User:
 
Comment:

 

Comments are limited to 250 characters (250 characters remaining)