|
|
|
|
|
Dicas
|
|
Visual Basic (Miscelâneas)
|
|
|
Título da Dica: Gerando senhas aleatórias
|
|
|
|
Postada em 6/10/2003 por ^HEAVY-METAL^
Public Function PassGen(Optional nLen As Integer = 8) As String Dim range As Collection Dim ivalue, icount Dim iLen As Long Dim pass As String
Set range = New Collection range.Add ("0") range.Add ("1") range.Add ("2") range.Add ("3") range.Add ("4") range.Add ("5") range.Add ("6") range.Add ("7") range.Add ("8") range.Add ("9") range.Add ("A") range.Add ("B") range.Add ("C") range.Add ("D") range.Add ("E") range.Add ("F") range.Add ("G") range.Add ("H") range.Add ("I") range.Add ("J") range.Add ("K") range.Add ("L") range.Add ("M") range.Add ("N") range.Add ("O") range.Add ("P") range.Add ("Q") range.Add ("R") range.Add ("S") range.Add ("T") range.Add ("U") range.Add ("V") range.Add ("W") range.Add ("X") range.Add ("Y") range.Add ("Z") range.Add ("a") range.Add ("b") range.Add ("c") range.Add ("d") range.Add ("e") range.Add ("f") range.Add ("g") range.Add ("h") range.Add ("i") range.Add ("j") range.Add ("k") range.Add ("l") range.Add ("m") range.Add ("n") range.Add ("o") range.Add ("p") range.Add ("q") range.Add ("r") range.Add ("s") range.Add ("t") range.Add ("u") range.Add ("v") range.Add ("w") range.Add ("x") range.Add ("y") range.Add ("z")
icount = 0 ivalue = 0 iLen = range.Count
Do Until icount = nLen Randomize ivalue = CByte(Mid(CStr(Rnd(GetTickCount)), 3, 2)) If ivalue > 0 And ivalue <= iLen Then icount = icount + 1 pass = pass & range(ivalue) End If Loop
PassGen = pass End Function
T+,
|
|
|
|
|