تابع تولید کننده رمز عبور (Password Generator)

تابع تولید کننده رمز عبور (Password Generator)
برای تولید رمزعبور قدرتمند میتونین از این تابع استفاده کنین:

Sub GenerateRandomPassword(numChars As Int, numbers As Boolean, lowercase As Boolean, uppercase As Boolean, symbols As Boolean) As String

Dim uppercaseArray() As String = Array As String ("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z")
Dim lowercaseArray() As String = Array As String ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
Dim numbersArray() As String = Array As String ("0","1","2","3","4","5","6","7","8","9")
Dim symbolsArray() As String = Array As String ("@","$","%","&","?","#","!","*","+","-",";","_")

Dim charList As List
charList.Initialize

If numbers Then charList.AddAll(numbersArray)
If lowercase Then charList.AddAll(lowercaseArray)
If uppercase Then charList.AddAll(uppercaseArray)
If symbols Then charList.AddAll(symbolsArray)

Dim newPassword As StringBuilder
newPassword.Initialize

For i = 1 To numChars
newPassword.Append(charList.Get(Rnd(0, charList.Size)))
Next

LogColor ("New password: " & newPassword.ToString, Colors.magenta)
Return newPassword

End Sub

از تابع بالا به این شکل استفاده کنین:

Dim pwd As String = GenerateRandomPassword(6, False, True, True, False)
Log("New password: " & pwd)

دیدگاهتان را بنویسید