I am fairly new at VB, and I am creating an application that requires a random generation of passwords of 8 characters. It has to be a mix of numeric, upper case and lower case letters. Any suggestions?
Do your know the Randomize and Rdn() functions ?<br>
<br>
See the help files and take an example from there, I think you may generate random numbers of ASCII code from by example, the code 64 to the code 128 I think, then you can have randomic ASCII character codes and then you translate them to "visible" characters.<br>
<br>
Try this and tell me about it!!
Here ya go:<br>
<br>
Function GeneratePassword() As String<br>
Dim ThisValue As Integer<br>
Dim ThisChar As String<br>
Dim Password As String<br>
<br>
Randomize<br>
Do<br>
ThisValue = Int((122 - 48 + 1) * Rnd + 48)<br>
Select Case ThisValue<br>
Case 48 To 57, 65 To 90, 97 To 122<br>
ThisChar = Chr$(ThisValue)<br>
Case Else<br>
ThisChar = ""<br>
End Select<br>
If Len(ThisChar) Then<br>
Password = Password & ThisChar<br>
End If<br>
Loop Until Len(Password) = 8<br>
GeneratePassword = Password<br>
End Function <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
Nick,
I just tried the random password generator you posted. THANK YOU. It really helped me out of a bind. That function was a bit too much for me to create as a beginner, but you really made my weekend. Thanx again
Id like to thank also to nick for sharing that code.. but i have another problem now.. i really got to create a random passwd but how can i decrypt it to its original value?
Public Function F_Encryption(ByVal sText As String) As String
Dim sPassword As String
Dim m As Long
Dim n As Integer
For m = 1 To Len(sText)
n = n - 1
If n < 1 Then n = Len(sPassword)
Mid$(sText, m, 1) = Chr$(Asc(Mid$(sText, m, 1)) Xor Asc(Mid$(sPassword, n, 1)))
Next
F_Encryption = sText
End Function
If I
Debug.Print F_Encryption("CCLINT"
It returns
?}pe`y
To de-crypt it I just sent it back
Debug.Print F_Encryption("?}pe`y"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.