Random Password Generator

Rastgele parola üretmek için sınıf

Public Class RandomPasswordGenerator
Private Shared ReadOnly AllCharacters As String = "ABCÇDEFGĞHIİJKLMNOÖPQRSŞTUÜVWXYZabcçdefgğhıijklmnoöpqrsştuüvwxyz0123456789!@#$%^&*()_+-=[]{}|;:,.<>?/\"
Private Shared ReadOnly AlphanumericCharacters As String = "ABCÇDEFGĞHIİJKLMNOÖPQRSŞTUÜVWXYZabcçdefgğhıijklmnoöpqrsştuüvwxyz"
Private Shared ReadOnly NumericCharacters As String = "0123456789"


Public Shared Function GenerateNumeric(length As Integer) As String
Dim password As New StringBuilder()
Using rng As New RNGCryptoServiceProvider()
Dim data(length - 1) As Byte
rng.GetBytes(data)

For Each b In data
Dim idx As Integer = b Mod NumericCharacters.Length
password.Append(NumericCharacters(idx))
Next
End Using
Return password.ToString()
End Function

Public Shared Function GenerateString(length As Integer) As String
Dim password As New StringBuilder()
Using rng As New RNGCryptoServiceProvider()
Dim data(length - 1) As Byte
rng.GetBytes(data)

For Each b In data
Dim idx As Integer = b Mod AlphanumericCharacters.Length
password.Append(AlphanumericCharacters(idx))
Next
End Using
Return password.ToString()
End Function


Public Shared Function GenerateStrong(length As Integer) As String
Dim password As New StringBuilder()
Using rng As New RNGCryptoServiceProvider()
Dim data(length - 1) As Byte
rng.GetBytes(data)

For Each b In data
Dim idx As Integer = b Mod AllCharacters.Length
password.Append(AllCharacters(idx))
Next
End Using
Return password.ToString()
End Function

End Class

Yorum yapın Yanıtı iptal et