Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SF Coders] Password Generator
#1
[Image: YzwzC.png]

Code:
Function GeneratePassword(Byval Length)
If (Length < 5) Then
            Length = 5 'Do not allow a password of length less than 5
        End If
        Dim alphabet As String() = Split("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,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", ",") 'Declare Our Alphabet
        Dim numbers As String() = Split("0,1,2,3,4,5,6,7,8,9", ",") 'Declare our numbers
        Dim Symbols As String() = Split("!,£,$,%,^,&,*,(,),{,},~,@,:,;,#,?,/,>,.,<", ",") 'Declare our symbols
        Dim Rand As New Random 'Declare our random
        Dim Password As String = "" ''Decalre our password as an empty string

        While (Password.Length() < length)
            If (Password.Length() = (length - 1)) Then
                Password += Symbols((Rand.Next(0, UBound(Symbols))))
            ElseIf Password.Length() >= (length - 3) Then
                Password += numbers(Rand.Next(0, UBound(numbers)))
            Else
                Password += alphabet(Rand.Next(0, UBound(alphabet)))
            End If
        End While
        Return Password
    End Function

After making the PHP version of this password generator (Which can be found here) I decided that I wanted to create a VB.Net version.

Usage:

PHP Code:
GeneratePassword(Length

Example:

PHP Code:
GeneratePassword(15

Output: xBUFaMJOtoTK45(

Enjoy. Smile
[Image: cooldude.png]

(09-05-2011, 08:36 AM)Orgy Wrote: If you understand what you're doing, you aren't learning anything. ;)
Reply
#2
Thanks for the share Dude , will take a look a it when i get time.
[Image: skyk.png]
Reply
#3
nice man Smile looks good, I may even use it in my custom password checker control if thats cool with you?
(and i can actually be bothered to update my control) lol, You will get credits of course Tongue
Reply
#4
Did this get re-posted?

Anyway well done for your first project, nice a cleanly done. Smile
Reply
#5
(12-06-2011, 11:30 AM)TrinityCoder Wrote: nice man Smile looks good, I may even use it in my custom password checker control if thats cool with you?
(and i can actually be bothered to update my control) lol, You will get credits of course Tongue

Sure thing. Smile

(12-06-2011, 11:31 AM)BreShiE Wrote: Did this get re-posted?

Anyway well done for your first project, nice a cleanly done. Smile

This is a VB.Net version. Tongue Smile
[Image: cooldude.png]

(09-05-2011, 08:36 AM)Orgy Wrote: If you understand what you're doing, you aren't learning anything. ;)
Reply
#6
Here is my version, uses random characters and a Select Case to make the password as random as possible.

I made it because most use the string array and it;s easier to use ASCII codes. You can also replace the whole Select Case and IF statements with a
PHP Code:
_Password += Chr(Random.Next(33126)) 
Which will give you a bit of everything if you don't want to make it selectable.

Function:

Usage:
PHP Code:
Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click
        TextBox1
.Text GeneratePassword(NumericUpDown1.Value)
    
End Sub 

Screenshot:
[Image: ?h=181ef61e312f744e140e95785704f7ea]
"If you cannot explain something simply, then you do not understand it at all." - Albert Einstein
"The best way to predict the future is to invent it." - Alan Kay
Reply
#7
Could i add more symbols and stuff? or will that make the password unusable on some websites...?
Reply
#8
(02-04-2012, 04:27 PM)Warp 1.9 Wrote: Could i add more symbols and stuff? or will that make the password unusable on some websites...?

I'm pretty sure this is just logical common sense, but it's up to you which symbols you want to use. You'd just be chancing it for which websites would allow certain symbols as password chars that's all. Otherwise, usually websites allow you free will over what kind of complex password you want.
Reply
#9
(02-04-2012, 06:22 PM)AceInfinity Wrote: I'm pretty sure this is just logical common sense, but it's up to you which symbols you want to use. You'd just be chancing it for which websites would allow certain symbols as password chars that's all. Otherwise, usually websites allow you free will over what kind of complex password you want.
What if i wanted it to spell a certain word in there somewhere but generate random characters around it?
Reply
#10
(02-04-2012, 07:39 PM)Warp 1.9 Wrote: What if i wanted it to spell a certain word in there somewhere but generate random characters around it?

Again, I would say exactly what i've just said.
Ace Wrote:I'm pretty sure this is just logical common sense, but it's up to you which symbols you want to use. You'd just be chancing it for which websites would allow certain symbols as password chars that's all. Otherwise, usually websites allow you free will over what kind of complex password you want.

That's simply just common sense.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SF Coders - Icon Changer - Project 1 Arron XR 14 3,871 09-11-2012, 08:20 PM
Last Post: malis2007
  [SF Coders]Imageshack.Us Image Scraper ★Cooldude★ 7 2,760 08-28-2012, 01:47 AM
Last Post: ★Cooldude★
  Adf.ly Direct Links Generator euverve 6 4,414 06-27-2012, 04:05 AM
Last Post: Ch4ng3m3
  [SF Coders] Grabbing an Icon from a File and Saving! [TUT] milopeach 13 3,169 05-15-2012, 06:22 PM
Last Post: OnyxDev
  [SF Coders] Converting between SteamID's and Friend Profile ID's milopeach 5 2,118 02-04-2012, 04:19 PM
Last Post: Denny Crane

Forum Jump:


Users browsing this thread: 5 Guest(s)