VB-Homepage Tipp 073

Paßwortver- & entschlüsselung

Ich denke das ist ein recht interessanter Tipp, denn wie oft hat man mit Passwörtern zu tun. Natürlich kann man die Information in irgendeine *.ini
oder sogar in die Registry eintragen.
Aber so richtig sicher ist es halt nur, wenn es auch verschlüsselt ist. Auch wenn es sich hier nicht um einen 56Byte Code handelt.
(Und selbst der ist schon geknackt wurden)

password.vbp
Form=password.frm
ProjWinSize=71,552,248,215
ProjWinShow=2
IconForm="Form1"
Title="password"
ExeName32="password.exe"
Name="Projekt1"
HelpContextID="0"
StartMode=0
VersionCompatible32="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName=""

password.frm
VERSION 4.00
Begin VB.Form Form1
Caption = "Beispiel Ver- & Entschlüsselung von Passwörtern"
ClientHeight = 4035
ClientLeft = 1140
ClientTop = 1515
ClientWidth = 7305
Height = 4440
Left = 1080
LinkTopic = "Form1"
ScaleHeight = 4035
ScaleWidth = 7305
Top = 1170
Width = 7425
Begin VB.TextBox Text2
Height = 375
Left = 5880
TabIndex = 5
Top = 600
Width = 735
End
Begin VB.TextBox Text1
Height = 615
Left = 600
MultiLine = -1 'True
TabIndex = 4
Top = 3000
Width = 6015
End
Begin VB.CommandButton Command3
Caption = "neuen Text setzen"
Height = 375
Left = 600
TabIndex = 3
Top = 2160
Width = 2415
End
Begin VB.CommandButton Command2
Caption = "Entschlüsseln"
Height = 375
Left = 1920
TabIndex = 2
Top = 600
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Verschlüsseln"
Height = 375
Left = 600
TabIndex = 0
Top = 600
Width = 1215
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
Caption = "© A.Gamper"
Height = 255
Left = 4560
TabIndex = 9
Top = 3720
Width = 2655
End
Begin VB.Label Label4
Caption = "Nur für Passwörter , keine langen Texte"
Height = 255
Left = 3360
TabIndex = 8
Top = 2280
Width = 3255
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "ungültig"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 255
Left = 5760
TabIndex = 7
Top = 360
Visible = 0 'False
Width = 975
End
Begin VB.Label Label2
Caption = "Ver- && Entschlüsselungsbyte ( <11 )"
Height = 615
Left = 4080
TabIndex = 6
Top = 480
Width = 1695
End
Begin VB.Label Label1
BorderStyle = 1 'Fixed Single
Caption = "Testtext"
Height = 495
Left = 600
TabIndex = 1
Top = 1200
Width = 6015
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Function DecryptPassword(Number As Byte, EncryptedPassword As String)
Dim Password As String, Counter As Byte
Dim Temp As Integer
On Error Resume Next
Counter = 1
Do Until Counter = Len(EncryptedPassword) + 1
Temp = Asc(Mid(EncryptedPassword, Counter, 1)) Xor (10 - Number)
If Counter Mod 2 = 0 Then
Temp = Temp + Number
Else
Temp = Temp - Number
End If
Password = Password & Chr$(Temp)
Counter = Counter + 1
Loop
DecryptPassword = Password
'wohin soll das verschlüsselte Password geschrieben werden
'In die Form
Label1.Caption = DecryptPassword
End Function
Function EncryptPassword(Number As Byte, DecryptedPassword As String)
Dim Password As String, Counter As Byte
Dim Temp As Integer
On Error Resume Next
Counter = 1
Do Until Counter = Len(DecryptedPassword) + 1
Temp = Asc(Mid(DecryptedPassword, Counter, 1))
If Counter Mod 2 = 0 Then
Temp = Temp - Number
Else
Temp = Temp + Number
End If
Temp = Temp Xor (10 - Number)
Password = Password & Chr$(Temp)
Counter = Counter + 1
Loop
EncryptedPassword = Password
'wohin soll das entschlüsselte Password geschrieben werden
'In die Form
Label1.Caption = EncryptedPassword
End Function
Private Sub Command1_Click()
'nur zum Fehler abfangen, da Eingaben über 10 Fehler verursachen und die Eingabe von Buchstaben keine sichere Verschlüsselung ergibt
'Verschlüsselung mit C läßt sich mit allen anderen Buchstaben wieder entschlüsseln
If Text2.Text = "0" Or Text2.Text = "1" Or Text2.Text = "2" Or Text2.Text = "3" Or Text2.Text = "4" Or Text2.Text = "5" Or Text2.Text = "6" Or Text2.Text = "7" Or Text2.Text = "8" Or Text2.Text = "9" Or Text2.Text = "10" Then
Label3.Visible = False
Call DecryptPassword(Val(Text2.Text), Label1.Caption)
Else
Label3.Visible = True
End If
End Sub
Private Sub Command2_Click()
If Text2.Text = "0" Or Text2.Text = "1" Or Text2.Text = "2" Or Text2.Text = "3" Or Text2.Text = "4" Or Text2.Text = "5" Or Text2.Text = "6" Or Text2.Text = "7" Or Text2.Text = "8" Or Text2.Text = "9" Or Text2.Text = "10" Then
Label3.Visible = False
Call EncryptPassword(Val(Text2.Text), Label1.Caption)
Else
Label3.Visible = True
End If
End Sub
Private Sub Command3_Click()
If Len(Text1.Text) > 3 Then
Label1.Caption = Text1.Text
End If
End Sub


Tipp-Download

Quelle :

Zurück zur Übersichtsseite