Public Function vernam_chiffre(original As String, skey As String) As String
Dim i As Long
Dim bCode As Byte
Dim bKey As Byte
Dim bResult As Byte
vernam_chiffre = ""
If Len(original) <> Len(skey) Then
MsgBox "Text und Key haben ungleiche Längen. " & _
"Verfahren kann nicht angewendet werden."
Exit Function
End If
For i = 1 To Len(original)
bCode = Asc(Mid(original, i, 1))
bKey = Asc(Mid(skey, i, 1))
bResult = bCode Xor bKey
vernam_chiffre = vernam_chiffre & Chr(bResult)
Next i
End Function
Nachteil is', dass key und original die selbe länge haben müssen, aber dafür ist dieses verfahren doch recht sicher.
m3rLiN
Dim i As Long
Dim bCode As Byte
Dim bKey As Byte
Dim bResult As Byte
vernam_chiffre = ""
If Len(original) <> Len(skey) Then
MsgBox "Text und Key haben ungleiche Längen. " & _
"Verfahren kann nicht angewendet werden."
Exit Function
End If
For i = 1 To Len(original)
bCode = Asc(Mid(original, i, 1))
bKey = Asc(Mid(skey, i, 1))
bResult = bCode Xor bKey
vernam_chiffre = vernam_chiffre & Chr(bResult)
Next i
End Function
Nachteil is', dass key und original die selbe länge haben müssen, aber dafür ist dieses verfahren doch recht sicher.
m3rLiN
mehr als ein LIPPER kann der Mensch kaum werden!