hab nen kleines problemchen, hat eigendlich nichts mit coding zu tuhen irgendiwe^^
also erstmal mein code:
Code:
Public Class Form1
Dim strSchlüssel As String
Private Sub txtPlain_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPlain.TextChanged
If Not txtPlain.Text = "" Then
txtSchlüssel.Enabled = False
Dim strCrypted As String = ""
For i As Long = 1 To Len(txtPlain.Text)
Dim strPlainStelle As String
strPlainStelle = Mid(txtPlain.Text, i, 1)
'If Int(Asc(strPlainStelle) + strSchlüssel) > 256 Then strCrypted = test
strCrypted = strCrypted & Chr(Int(Asc(strPlainStelle) + strSchlüssel))
Next i
txtCrypted.Text = strCrypted
Else
txtSchlüssel.Enabled = True
txtCrypted.Text = ""
End If
End Sub
Private Sub txtSchlüssel_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSchlüssel.TextChanged
If Not txtSchlüssel.Text = "" Then
For i As Long = 1 To Len(txtSchlüssel.Text)
Dim strStelle As String
strStelle = Mid(txtSchlüssel.Text, i, 1)
strSchlüssel = strSchlüssel & Asc(strStelle)
Next i
strSchlüssel = Int((strSchlüssel Mod 42))
Else
strSchlüssel = ""
End If
End Sub
End Class
(denke mal länge is noch ok, wenn nich kann ichs gerne als nopaste machen)
also soweit funktioniert der code, ABER^^
es kommt ein error wenn der asc code 256 übersteigt, weils dafür kein zeichen gibt, wenn ich nen if einbaue der 256 abfragt kann ich zwar ne ausnahme machen (zB. if asc(zeichen + schlüssel) > 256 then crypted = wasweißich) aber das zeichen muss ja trotzdem so gecryptet werden wie die anderen um es wieder zu decrypten, oder wie soll ich beim decrypten erkennen welches zeichen ne ausnahme war? ~.~