Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating passwords 4

Status
Not open for further replies.

allyeric

Programmer
Mar 14, 2000
104
CA
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 &quot;visible&quot; 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 = &quot;&quot;<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

Brianjay
bj.ele@verizon.net
 
Hi there,

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?

yjoke
 
Try this (uses XOR):

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(&quot;CCLINT&quot;)

It returns
?}pe`y

To de-crypt it I just sent it back
Debug.Print F_Encryption(&quot;?}pe`y&quot;)

And it returns
CCLINT

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top