шифрование


АССИМИТРИЧНЫЙ КЛЮЧ
Private Sub CommandButton1_Click()Dim i, j, p, q, e, d, n, c, ks As Integer
Dim s, string1, string2, Strq As String
string1 = TextBox3.Text
p = CDbl(TextBox1.Text)
q = CDbl(TextBox2.Text)
e = CDbl(TextBox4.Text)
n = p * q
For i = 1 To Len(string1)
c = Asc(Mid(string1, i, 1))
ks = 1
For j = 1 To e
ks = ks * c Mod n
Next j
s = Chr(ks)
Strq = Strq & s
Next iTextBox5.Text = StrqEnd Sub
Private Sub CommandButton2_Click()string2 = TextBox5.Text
p = CDbl(TextBox1.Text)
q = CDbl(TextBox2.Text)
d = CDbl(TextBox6.Text)
n = p * q
For i = 1 To Len(string2)
c = Asc(Mid(string2, i, 1))
ks = 1
For j = 1 To d
ks = ks * c Mod n
Next j
s = Chr(ks)
Strq = Strq & s
Next iTextBox7.Text = StrqEnd Sub
Private Sub CommandButton3_Click()Hide
End Sub
Private Sub Label5_Click()End Sub
ЗАКРЫТЫЙ КЛЮЧ
Private Sub CommandButton1_Click()Dim mess, key, res As String
Dim i, m, k As Integer
mess = TextBox1.Text
key = TextBox2.Text
res = ""
For i = 1 To Len(mess) Step 1
m = Asc(Mid(mess, i, 1))
k = Asc(Mid(key, 1 + i Mod Len(key), 1))
res = res + Chr((m + k) - 65)
Next i
TextBox1.Text = res
End Sub
Private Sub CommandButton2_Click()Dim mess, key, res As String
Dim j, m, k As Integer
mess = TextBox1.Text
key = TextBox2.Text
res = ""
For i = 1 To Len(mess) Step 1
m = Asc(Mid(mess, i, 1))
k = Asc(Mid(key, 1 + i Mod Len(key), 1))
res = res + Chr((m - k) + 65)
Next i
TextBox3.Text = res
End SubPrivate Sub CommandButton3_Click()
HideEnd Sub

Приложенные файлы

  • docx 739812
    Размер файла: 14 kB Загрузок: 0

Добавить комментарий