08-04-18, 11:25 AM
(08-04-18, 04:15 AM)silverlight كتب : يمكنك استخدام الدالة التالية
وهي تستخدم للتشفيير و أيضا تستخدم في فك التشفيير
PHP كود :
Private Function Vigenere(data As String, password As String, encrypt As Boolean) As String
For i As Integer = 0 To password.Length - 1
If Not Char.IsLetter(password(i)) Then
Return Nothing
End If
Next
Dim result As String = String.Empty
Dim count As Integer = 0
For i As Integer = 0 To data.Length - 1
If Char.IsLetter(data(i)) Then
Dim IsUpper As Boolean = Char.IsUpper(data(i))
Dim index As Integer = Convert.ToInt32(If(IsUpper, "A"c, "a"c))
Dim passwordIndex As Integer = (i - count) Mod password.Length
Dim j As Integer = Convert.ToInt32(If(IsUpper, Char.ToUpper(password(passwordIndex)), Char.ToLower(password(passwordIndex)))) - index
j = If(encrypt, j, -j)
Dim a As Integer = ((Convert.ToInt32(data(i)) + j) - index)
Dim b As Integer = 26
Dim c As Integer = (a Mod b + b) Mod b
Dim chr As Char = ChrW(c + index)
result += chr
Else
result += data(i)
count += 1
End If
Next
Return result
End Function
التشفيير
PHP كود :
Dim txt As String = "Visual Basic For Arab"
Dim password As String = "password"
Dim encrypted As String = Me.Vigenere(txt, password, True)
فك التشفيير
PHP كود :
Dim decrypted = Me.Vigenere(encrypted, password, False)
شكرا لك ممكن تضع مشروع هيك بسيط لاني بدي افهمه مشان راح اطبقو بعد ما افهمه واطور عليه
