Advanced safe login system

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
3 posts Page 1 of 1
Contributors
User avatar
Ffenixw0rks
VIP - Donator
VIP - Donator
Posts: 152
Joined: Sun Jun 19, 2011 2:51 pm

Advanced safe login system
Ffenixw0rks
This tutorial will be about some safe login(as it should be).

Why it's safe? Answer: no textbox for password input. I think it should be safe :D

Lets start!
1)Add new form / or use existing.
2)Add 1 textbox, button, label and label for 'Username:' text if you need it.
Image
Some debug labels out there... lmao;

3)Set KeyPreview option in form to True.
4)Time for coding...
Public variables:
Code: Select all
Dim listn As Boolean = False
    Dim pass(MAX_PASS_LENGTH) As String
    Dim i As Integer = 0
Explain:
listn - when to start capturing key presses.
pass(MAX_PASS_LENGTH) - array to store chars.
i - used to make string from array.

Next. Text for label: 'Click me to start saving pass' or something like that.

Code for mouse click on label:
Code: Select all
If listn = False Then
            TextBox1.Enabled = False
            Label2.Text = "Listening to keys... Press me to stop(without save)."
            Label4.Text = "Saved chars: " & i 'FOR DEBUG ONLY
            Label2.Select()
            listn = True
        Else
            TextBox1.Enabled = True
            Label2.Text = "Click me to start saving pass"
            Label4.Text = "Click label to start." ' FOR DEBUG ONLY
            ReDim pass(MAX_PASS_LENGTH)
            i = 0
            listn = False
        End If
No need to explain here i think.

Now on Form KeyPress event:
Code: Select all
If listn = True Then
            If ass <= MAX_PASS_LENGTH Then
                pass(i) = e.KeyValue
                i += 1
                Label4.Text = "Saved chars: " & i ' DEBUG
            End If
        End If
Explain: Adding pressed char in place at array.

Finaly! On login button:
Code: Select all
Dim v As Integer
        Dim repass As String = ""
        For v = 0 To MAX_PASS_LENGTH
            If pass(v) = "" Then
            Else
                repass = repass + ChrW(pass(v))
            End If
        Next
        If TextBox1.Text = "USER_HERE" And repass.ToLower = "PASS_HERE" Then
            MsgBox("Logined!") ' User logined.
        End If
Explain:
repass - string for changing array into string.
For ... - convert char in array to char in string, dropping if empty.

And that's about it. If you have any questions - ask here!

P.S.: I think you can add chars into string to check from the beginning :D
Image
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Advanced safe login system
MrAksel
This is just as safe as a TextBox. With a TextBox you can set the UseSystemPasswordChar property (or something like that) which makes it unreadable, just as your code :) Nice work though cooll;
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Ffenixw0rks
VIP - Donator
VIP - Donator
Posts: 152
Joined: Sun Jun 19, 2011 2:51 pm

Re: Advanced safe login system
Ffenixw0rks
MrAksel wrote:
This is just as safe as a TextBox. With a TextBox you can set the UseSystemPasswordChar property (or something like that) which makes it unreadable, just as your code :) Nice work though cooll;
Maybe, it's safe because it not displays how many characters you typed in. Or, it will be just advanced :D
Image
3 posts Page 1 of 1
Return to “Tutorials”