Password Encrypting: Visual Basic 6.0
Posted: Sat Jan 14, 2006 6:54 pm
Ok so this is the source code of the Visual Basic 6.0 password protected form. If you want a list of passwords that will work with the demo program I released, locate the list at the bottom of the post. If anyone didn't know there was a hacking challenge, the thread is here.
NOTE: The names of some variables or procedures may differ from example program. Also, only chunks of code relative the checking the password are shown. Variables are represented with blue text.
The point of the program is that multiple passwords can be used and there's a huge range of possibilities.
Form1:
frmSuccess:
Now to explain the important parts:
This is the basic key element of the form right here. CSum is in this case is what I am reffering 'Character Sum' as.
In this loop, the string is converted to an integer one character at a time using this encryption method I wrote. This is what defines the loop to go through each character.
So the variable i represents the character we are on and increases by one each time.
Let's break it down more. This case is if the character is a number:
The integer value of 'Character' (a temporary variable) is based on vb's method of getting the ASCII value of the character and 50 and then the Character value of that number. Since Character is an integer variable it stores this information by integer. So the CSum variable is updated to the new value with the ASCII value of Character.
This is for if the current character is a letter:
As you can see it's the same encryption except that 100 is being added to it instead.
Since the CSum is never reset. If the password fails once, it's most likely to never succeed again espcially if the sum exceeds 1661 which doesn't take that many characters.
Now here is the basic use of the sum in the if statement of the command button:
If the sum adds up to 1661 then store that to a textbox in the other form and load it.
Code for frmSuccess:
This checks if the value is corrent by performing a clever stupid little thing I did with variable tricks:
RSum is dimmed as an integer and recieves the default value of 0.
Mult is a string which is stored as the sum of 0 and 1. Mult = 1
Mult is a string so the operator '+' in this statement is used to combine two strings so now Mult = 11
RSum is an integer being set to store the product of Mult(11) and 151. RSum = 1661 which is the the value that was stored in the tw224 textbox if the user typed the password in correctly. This if statment block double checks that:
So I just chose 1661 as my integer sum because it worked well with many passwords. If you would like to make one of these I recommend making a program that will return the value of the encrypted sum before you finalize the project.
Passwords that will work with this (and the demo program)
Since the encryption I wrote does not care about order, the strings you see may be entered with the characters in any order. And there are still many more passwords possible to work with this.
If you did not download the demo program while the hack challenge was going on here it is.
'Protect' in a zip file
Hope this is useful
NOTE: The names of some variables or procedures may differ from example program. Also, only chunks of code relative the checking the password are shown. Variables are represented with blue text.
The point of the program is that multiple passwords can be used and there's a huge range of possibilities.
Form1:
Code: Select all
Dim Password As String
Dim CSum As Integer
Public Function PasswordEncrypt(inputpassword As String) As String
Dim Character As String, i As Integer
Character = ""
Dim TextLength As Integer
TextLength = Len(inputpassword)
For i = 1 To TextLength
Character = Mid(inputpassword, i, 1)
Select Case Asc(Character)
Case 48 To 57
Character = Chr(Asc(Character) + 50)
CSum = CSum + Asc(Character)
Case 65 To 122
Character= Chr(Asc(Character) + 100)
CSum = CSum + Asc(Character)
End Select
Next
End Function
Private Sub Login_Click()
PasswordLock txtencrypt.Text
Password = ""
If CSum = 1661 Then
Me.tw224.Text = CSum
frmSuccess.Show
Unload Me
Else
FailedLogin
End If
End Sub
Private Sub Form_Load()
CSum = 0
nBeep = 0
End Sub
Private Sub FailedLogin()
tmrBeep.Enabled = True
End Sub
Code: Select all
Private Sub Form_Load()
Dim RSum As Integer
Dim Mult As String
Mult = RSum + 1
Mult = Mult + Mult
RSum = Mult * 151
If Form1.tw224.Text <> RSum Then
Unload Me
End If
End Sub
Code: Select all
Dim CSum As Integer
In this loop, the string is converted to an integer one character at a time using this encryption method I wrote. This is what defines the loop to go through each character.
Code: Select all
Dim TextLength As Integer
TextLength = Len(inputpassword)
Code: Select all
For i = 1 To TextLength
Character = Mid(inputpassword, i, 1)
Select Case Asc(Character)
Case 48 To 57
Character = Chr(Asc(Character) + 50)
CSum = CSum + Asc(Character)
Case 65 To 122
Character = Chr(Asc(Character) + 100)
CSum = CSum + Asc(Character)
End Select
Next
Code: Select all
Case 48 To 57
Character = Chr(Asc(Character) + 50)
CSum = CSum + Asc(Character)
This is for if the current character is a letter:
Code: Select all
Case 65 To 122
Character = Chr(Asc(Character) + 100)
CSum = CSum + Asc(Temp)
Since the CSum is never reset. If the password fails once, it's most likely to never succeed again espcially if the sum exceeds 1661 which doesn't take that many characters.
Now here is the basic use of the sum in the if statement of the command button:
Code: Select all
If CSum = 1661 Then
Me.tw224.Text = CSum
frmSuccess.Show
Unload Me
Else
FailedLogin
End If
Code for frmSuccess:
Code: Select all
Private Sub Form_Load()
Dim RSum As Integer
Dim Mult As String
Mult = RSum + 1
Mult = Mult + Mult
RSum = Mult * 151
If Form1.tw224.Text <> RSum Then
Unload Me
End If
End Sub
Code: Select all
Dim RSum As Integer
Code: Select all
Dim Mult As String
Mult = RSum + 1
Code: Select all
Mult = Mult + Mult
Code: Select all
RSum = Mult * 151
Code: Select all
If Form1.tw224.Text <> RSum Then
Unload Me
End If
Passwords that will work with this (and the demo program)
Code: Select all
yellow00a
pinkdog98
tealgun67
orange6999
cyanredw
smoking14
asshole77
sodazman
If you did not download the demo program while the hack challenge was going on here it is.
'Protect' in a zip file
Hope this is useful
