LAMPIRAN A: LISTING PROGRAM
LAMPIRAN A: LISTING PROGRAM
FORM MENU UTAMA Dim Ymouse, Xmouse, dy(30), dx(30), Da(30), Mo(30) Dim Split1, Day1, Year1, Todaysdate, h, m, D, S, Face, Speed, n, scrll Dim Dsplit, HandHeight, Handwidth, HandX, HandY, Step, currStep Dim Test, ClockHeight, ClockWidth, ClockFromMouseY, ClockFromMouseX Dim Fcol, Mcol, Scol, Hcol, Dcol Private Type FL T(30) As Long Le(30) As Long End Type Dim FL As FL Private Type HL T(30) As Long Le(30) As Long End Type Dim HL As HL Private Type SL T(30) As Long Le(30) As Long End Type Dim SL As SL Private Type ML T(30) As Long Le(30) As Long End Type Dim ML As ML Private Type DL T(30) As Long Le(30) As Long End Type Dim DL As DL Const PI = 3.1415 Private Declare Function GetActiveWindow Lib "user32" () As Long Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Universitas Sumatera Utara
Const SW_SHOWNORMAL = 1 Private Sub Sub_Menu_Cari_Bilangan_Prima_Click() Form_Bilangan_Prima.Show vbModal End Sub Private Sub Sub_Menu_Pembentukan_Kunci_Click() Form_Pembentukan_Kunci.Show vbModal End Sub Private Sub Sub_Menu_Proses_Enkripsi_Click() Form_Enkripsi.Show vbModal End Sub Private Sub Timer1_Timer() dy(0) = dy(0) + (Ymouse - dy(0)) * Speed dy(0) = Fix(dy(0)) dx(0) = dx(0) + (Xmouse - dx(0)) * Speed dx(0) = Fix(dx(0)) For i = 1 To Len(D) - 1 dy(i) = dy(i) + (dy(i - 1) - dy(i)) * Speed dy(i) = Fix(dy(i)) dx(i) = dx(i) + (dx(i - 1) - dx(i)) * Speed dx(i) = Fix(dx(i)) Next i secs = Second(Now) sec = -1.57 + PI * secs / 30 Mins = Minute(Now) Min = -1.57 + PI * Mins / 30 hr = Hour(Now) hrs = -1.575 + PI * hr / 6 + PI * Int(Minute(Now)) / 360 For i = 0 To n - 2 FL.T(i) = dy(i) + ClockHeight * Sin(-1.0471 + i * Split1 * PI / 180) + scrll FL.Le(i) = dx(i) + ClockWidth * Cos(-1.0471 + i * Split1 * PI / 180) Next i For i = 0 To Len(h) - 1 HL.T(i) = dy(i) + HandY + (i * HandHeight) * Sin(hrs) + scrll HL.Le(i) = dx(i) + HandX + (i * Handwidth) * Cos(hrs) Next i For i = 0 To Len(m) - 1 ML.T(i) = dy(i) + HandY + (i * HandHeight) * Sin(Min) + scrll ML.Le(i) = dx(i) + HandX + (i * Handwidth) * Cos(Min)
Universitas Sumatera Utara
Next i For i = 0 To Len(S) - 1 SL.T(i) = dy(i) + HandY + (i * HandHeight) * Sin(sec) + scrll SL.Le(i) = dx(i) + HandX + (i * Handwidth) * Cos(sec) Next i For i = 0 To Len(D) - 1 DL.T(i) = dy(i) + ClockHeight * 1.5 * Sin(currStep + i * Dsplit * PI / 180) + scrll DL.Le(i) = dx(i) + ClockWidth * 1.5 * Cos(currStep + i * Dsplit * PI / 180) Next i currStep = currStep - Step P End Sub Private Function SP(ByVal ST As String, ByVal Nu As Integer, Optional K As Byte = 1) As String SP = Mid(ST, Nu + 1, K) End Function Private Sub P() Cls With Form_Menu_Utama .FontBold = False .ForeColor = Dcol For i = 0 To Len(D) - 1 .CurrentY = DL.T(i) .CurrentX = DL.Le(i) Print SP(D, i) Next i .ForeColor = Fcol For i = 0 To n - 1 .CurrentY = FL.T(i) .CurrentX = FL.Le(i) If (i = 18 Or i = 20 Or i = 22) Then Print SP(Face, i, 2) i=i+1 Else Print SP(Face, i, 1) End If Next i .FontBold = True .ForeColor = Scol For i = 0 To Len(S) - 1 .CurrentY = SL.T(i) .CurrentX = SL.Le(i)
Universitas Sumatera Utara
Print SP(S, i) Next i .ForeColor = Mcol For i = 0 To Len(m) - 1 .CurrentY = ML.T(i) .CurrentX = ML.Le(i) Print SP(m, i) Next i .ForeColor = Hcol For i = 0 To Len(h) - 1 .CurrentY = HL.T(i) .CurrentX = HL.Le(i) Print SP(h, i) Next i End With End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Ymouse = y + ClockFromMouseY ':event.y+ClockFromMouseY; Xmouse = x + ClockFromMouseX ':event.x+ClockFromMouseX; End Sub Private Sub Form_Load() Timer1.Interval = 15 Me.BackColor = &H808080 Dcol = vbBlue Fcol = vbRed Scol = vbGreen Mcol = vbYellow Hcol = vbBlack ClockHeight = 750 ClockWidth = 750 ClockFromMouseY = 1200 ClockFromMouseX = 600 Da(1) = " SUNDAY": Da(2) = " MONDAY": Da(3) = " TUESDAY": Da(4) = "WEDNESDAY" Da(5) = "THURSDAY": Da(6) = " FRIDAY": Da(7) = " SATURDAY" Mo(1) = "JANUARY": Mo(2) = "FEBRUARY": Mo(3) = "MARCH" Mo(4) = "APRIL": Mo(5) = "MAY": Mo(6) = "JUNE": Mo(7) = "JULY" Mo(8) = "AUGUST": Mo(9) = "SEPTEMBER": Mo(10) = "OCTOBER" Mo(11) = "NOVEMBER": Mo(12) = "DECEMBER" Day1 = Day(Now) Year1 = Year(Now) If (Year1 < 2000) Then Year1 = Year1 + 1900 Todaysdate = " " + Da(Weekday(Now)) + " " + Str(Day1) + " " + Mo(Month(Now)) + " " + Str(Year1) D = Todaysdate
Universitas Sumatera Utara
h = "****" m = "*****" S = "******" Face = "1 2 3 4 5 6 7 8 9 1011122 " Form_Menu_Utama.Font = "Bernard MT Condensed" Form_Menu_Utama.FontSize = 11 Speed = 0.6 n = Len(Face) - 2 Ymouse = 0 Xmouse = 0 scrll = 0 Split1 = 360 / n Dsplit = 360 / Len(D) HandHeight = ClockHeight / 6 Handwidth = ClockWidth / 6 HandY = -7 HandX = -2.5 scrll = 1 * ClockHeight Step = 0.06 currStep = 0 End Sub Private Sub Menu_Keluar_Click() Dim Pesan As String Pesan = MsgBox(" Anda yakin untuk keluar dari aplikasi ini? ", vbInformation + vbOKCancel, "Keluar") If Pesan = vbOK Then End End If End Sub Private Sub Sub_Menu_Kalkulator_Click() On Error Resume Next Shell ("calc"), vbMinimizedFocus Exit Sub End Sub Private Sub Sub_Menu_Windows_Explorer_Click() On Error Resume Next Shell ("explorer"), vbMaximizedFocus Exit Sub End Sub Form Enkripsi Dim PH As Integer Dim HP As Integer Dim Pemberitahuan Dim n As Byte
Universitas Sumatera Utara
Private Sub Form_Activate() Text2.Text = 2 Text61.Text = 1 Text62.Text = 1 End Sub Private Sub Form_Load() Pemberitahuan = " Untuk melakukan proses enkripsi pesan, terlebih dahulu tentukan nilai-nilai kunci untuk proses enkripsi, dan selanjutnya isikan pesan pribadi anda pada kotak isian plaintext dibawah.! " txt_kunci_p.Text = 0 txt_kunci_q.Text = 0 txt_nilai_n.Text = 0 txt_totient.Text = 0 txt_nilai_e.Text = 0 txt_nilai_d.Text = 0 txt_plain1.Text = "" txt_chiper1.Text = "" End Sub Private Function GenNumber() As Integer Dim P As Integer P = 2 * CInt(Int((50 * Rnd))) + 1 If IsPrima(P) = True Then GenNumber = P Else Dim A As Integer A = GenNumber() GenNumber = A End If
End Function Private Function IsPrima(x As Integer) As Integer Dim i, j As Integer Dim T As Boolean i=x T = True For j = 2 To (i - 1) If i Mod j = 0 Then T = False Exit For
Universitas Sumatera Utara
End If Next j IsPrima = T End Function Private Sub pb_kunci_p_Click() Me.txt_kunci_p.Text = GenNumber() If txt_kunci_p.Text = 1 Then txt_kunci_p.Text = 3 End If If Val(txt_kunci_p.Text) = Val(txt_kunci_q.Text) Then pb_kunci_p_Click pb_kunci_p_Click End If End Sub
Private Sub pb_kunci_q_Click() Dim Q As Integer Q = 2 * CInt(Int((50 * Rnd))) + 1 Me.txt_kunci_q.Text = Q If txt_kunci_q.Text = 1 Then txt_kunci_q.Text = 2 End If If Val(txt_kunci_q.Text) = Val(txt_kunci_p.Text) Then pb_kunci_q_Click pb_kunci_q_Click End If End Sub Private Sub pb_hitung_n_Click() If txt_kunci_p.Text = 0 Then MsgBox "Nilai kunci (P) = 0" & vbCrLf & _ "Tentukan nilai kunci (P) untuk dapat menghitung nilai (n)!", vbExclamation, "Nilai Kosong!" pb_kunci_p.SetFocus Exit Sub End If If txt_kunci_q.Text = 0 Then MsgBox "Nilai kunci (Q) = 0" & vbCrLf & _ "Tentukan nilai kunci (Q) untuk dapat menghitung nilai (n)!", vbExclamation, "Nilai Kosong!"
Universitas Sumatera Utara
pb_kunci_q.SetFocus Exit Sub End If Dim n As Integer n = Val(txt_kunci_p) * Val(txt_kunci_q) Me.txt_nilai_n.Text = n End Sub Private Sub pb_hitung_totient_Click() If txt_kunci_p.Text = 0 Then MsgBox "Nilai kunci (P) = 0" & vbCrLf & _ "Tentukan nilai kunci (P) untuk dapat menghitung nilai (n)!", vbExclamation, "Nilai Kosong!" pb_kunci_p.SetFocus Exit Sub End If If txt_kunci_q.Text = 0 Then MsgBox "Nilai kunci (Q) = 0" & vbCrLf & _ "Tentukan nilai kunci (Q) untuk dapat menghitung nilai (n)!", vbExclamation, "Nilai Kosong!" pb_kunci_q.SetFocus Exit Sub End If If txt_nilai_n.Text = 0 Then MsgBox "Nilai (n) = 0" & vbCrLf & _ "Tentukan nilai (n) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" pb_hitung_n.SetFocus Exit Sub End If Dim Totient As Integer Totient = (Val(txt_kunci_p - 1)) * (Val(txt_kunci_q - 1)) Me.txt_totient.Text = Totient End Sub Private Sub pb_kunci_e_Click() Clear If txt_kunci_p.Text = 0 Then MsgBox "Nilai kunci (P) = 0" & vbCrLf & _ "Tentukan nilai kunci (P) untuk dapat menghitung nilai (e)!", vbExclamation, "Nilai Kosong!" pb_kunci_p.SetFocus Exit Sub End If
Universitas Sumatera Utara
If txt_kunci_q.Text = 0 Then MsgBox "Nilai kunci (Q) = 0" & vbCrLf & _ "Tentukan nilai kunci (Q) untuk dapat menghitung nilai (e)!", vbExclamation, "Nilai Kosong!" pb_kunci_q.SetFocus Exit Sub End If If txt_nilai_n.Text = 0 Then MsgBox "Nilai (n) = 0" & vbCrLf & _ "Tentukan nilai (n) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" pb_hitung_n.SetFocus Exit Sub End If If txt_totient.Text = 0 Then MsgBox "Nilai (totient n) = 0" & vbCrLf & _ "Tentukan nilai (totient n) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" txt_totient.Text = 0 Text1.Text = 0 Text2.Text = 2 pb_hitung_totient.SetFocus Exit Sub End If Call Hitung If Text300 <> 1 Then Text2.Text = Val(Text2) + 1 Hitung pb_kunci_e_Click Else txt_nilai_e.Text = Text200.Text End If End Sub Private Sub pb_kunci_d_Click() If txt_kunci_p.Text = 0 Then MsgBox "Nilai kunci (P) = 0" & vbCrLf & _ "Tentukan nilai kunci (P) untuk dapat menghitung nilai (d)!", vbExclamation, "Nilai Kosong!" pb_kunci_p.SetFocus Exit Sub End If If txt_kunci_q.Text = 0 Then
Universitas Sumatera Utara
MsgBox "Nilai kunci (Q) = 0" & vbCrLf & _ "Tentukan nilai kunci (Q) untuk dapat menghitung nilai (d)!", vbExclamation, "Nilai Kosong!" pb_kunci_q.SetFocus Exit Sub End If If txt_nilai_n.Text = 0 Then MsgBox "Nilai (n) = 0" & vbCrLf & _ "Tentukan nilai (n) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" pb_hitung_n.SetFocus Exit Sub End If If txt_totient.Text = 0 Then MsgBox "Nilai totient(n) belum diketahui," & vbCrLf & _ "Tentukan nilai totient(n) terlebih dahulu dalam proses pembentukan kunci enkripsi, dan selanjutnya lakukan proses nilai kunci dekripsi (d)!", vbExclamation, "Nilai Kosong!" pb_hitung_totient.SetFocus Exit Sub End If If txt_nilai_e.Text = 0 Then MsgBox "Nilai (e) = 0" & vbCrLf & _ "Tentukan nilai (e) terlebih dahulu untuk dapat menghitung nilai (d)!", vbExclamation, "Nilai Kosong!" pb_kunci_e.SetFocus Exit Sub End If Dim Normal As Double Dim Test As Double Dim Totient As Double Dim Per As Double Dim Kali As Double Dim Tambah As Double Dim Dapat As Double Normal = Val(Text61.Text) Test = Val(Text62.Text) Totient = Val(Text63.Text) Per = Val(Text64.Text) Kali = Val(Test * Totient) Tambah = Val(Normal + Kali) Dapat = Val(Tambah Mod Per)
Universitas Sumatera Utara
If Val(Dapat) <> 0 Then Text62.Text = Val(Text62) + 1 Dim Lagi As Double Lagi = Val(Tambah) / Val(Per) Me.txt_nilai_d.Text = Lagi pb_kunci_d_Click Else Dim Jadi As Double Jadi = Val(Tambah) / Val(Per) Me.txt_nilai_d.Text = Jadi End If txt_chiper1.Text = "" txt_plain1.SetFocus End Sub Private Sub pb_kirim_Click() If txt_chiper1.Text = "" Then MsgBox "Chipertext (pesan yang akan dikirim) belum ada proses enkripsi" & vbCrLf &_ "Lakukan proses enkripsi terlebih dahulu untuk dapat mengirim pesan chipertext!", vbExclamation, "Nilai Chipertext Kosong" txt_plain1.SetFocus Exit Sub Else With Form_Dekripsi .Caption = "Form Dekripsi" .txt_chiper2.Text = txt_chiper1.Text .txt_simpan.Text = txt_plain1.Text .nilai_n.Text = txt_nilai_n.Text .txt_nilai_d2.Text = txt_nilai_d End With Unload Me Form_Dekripsi.Show vbModal End If End Sub Private Sub pb_enkripsi_Click() If txt_kunci_p.Text = 0 Then MsgBox "Nilai kunci (P) = 0" & vbCrLf & _ "Tentukan nilai kunci (P) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" pb_kunci_p.SetFocus Exit Sub End If If txt_kunci_q.Text = 0 Then MsgBox "Nilai kunci (Q) = 0" & vbCrLf & _
Universitas Sumatera Utara
"Tentukan nilai kunci (Q) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" pb_kunci_q.SetFocus Exit Sub End If If txt_nilai_n.Text = 0 Then MsgBox "Nilai (n) = 0" & vbCrLf & _ "Tentukan nilai (n) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" pb_hitung_n.SetFocus Exit Sub End If If txt_totient.Text = 0 Then MsgBox "Nilai totient(n) belum diketahui," & vbCrLf & _ "Tentukan nilai totient(n) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" pb_hitung_totient.SetFocus Exit Sub End If If txt_nilai_e.Text = 0 Then MsgBox "Nilai (e) = 0" & vbCrLf & _ "Tentukan nilai (e) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" pb_kunci_e.SetFocus Exit Sub End If If txt_nilai_d.Text = 0 Then MsgBox "Nilai (d) = 0" & vbCrLf & _ "Tentukan nilai (d) terlebih dahulu untuk melakukan proses enkripsi dengan benar!", vbExclamation, "Nilai Kosong!" pb_kunci_d.SetFocus Exit Sub End If Dim Inputan As String Dim Panjang_Input As Variant Dim Konversi As String Dim Pangkat As String Dim Hasil As Long Dim i As Variant Dim c As Byte Dim Output As String Inputan = txt_plain1.Text Panjang_Input = Len(txt_plain1.Text)
Universitas Sumatera Utara
For i = 1 To Panjang_Input Konversi = Mid(Inputan, i, 1) Konversi = Asc(Konversi) Pangkat = Val(txt_nilai_e) Hasil = 1 For c = 1 To Pangkat Hasil = (Hasil * Konversi) Mod Val(txt_nilai_n) Next Hasil1 = Hasil & Space(2) Output = Output & Hasil1 Next i txt_chiper1.Text = Output End Sub Private Sub pb_hapus_Click() txt_kunci_p.Text = 0 txt_kunci_q.Text = 0 txt_nilai_n.Text = 0 txt_nilai_e.Text = 0 txt_nilai_d.Text = 0 txt_totient.Text = 0 txt_plain1.Text = "" txt_chiper1.Text = "" End Sub Sub Hitung() Clear Text1.Text = Val(txt_totient.Text) If Text2.Text = 0 Then Text2.Text = Val(Text2.Text) + 1 End If Text41.Text = Val(Text1) Mod Val(Text2) If Val(Text41) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = Val(Text41) Else Text100 = 0 Text200 = 0 Text300 = 0 End If If Val(Text41.Text) <> 0 Then Text3.Text = Val(Text2) Text4.Text = Val(Text41)
Universitas Sumatera Utara
Text42.Text = Val(Text3) Mod Val(Text4) End If If Val(Text42) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 Else End If If Val(Text42.Text) <> 0 Then Text5.Text = Val(Text4) Text6.Text = Val(Text42) Text43.Text = Val(Text5) Mod Val(Text6) End If If Val(Text43) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text43.Text) <> 0 Then Text7.Text = Val(Text6) Text8.Text = Val(Text43) Text44.Text = Val(Text7) Mod Val(Text8) End If If Val(Text44) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text44.Text) <> 0 Then Text9.Text = Val(Text8) Text10.Text = Val(Text44) Text45.Text = Val(Text9) Mod Val(Text10) End If If Val(Text45) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text45.Text) <> 0 Then Text11.Text = Val(Text10) Text12.Text = Val(Text45)
Universitas Sumatera Utara
Text46.Text = Val(Text11) Mod Val(Text12) End If If Val(Text46) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text46.Text) <> 0 Then Text13.Text = Val(Text12) Text14.Text = Val(Text46) Text47.Text = Val(Text13) Mod Val(Text14) End If If Val(Text47) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text47.Text) <> 0 Then Text15.Text = Val(Text14) Text16.Text = Val(Text47) Text48.Text = Val(Text15) Mod Val(Text16) End If If Val(Text48) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text48.Text) <> 0 Then Text17.Text = Val(Text16) Text18.Text = Val(Text48) Text49.Text = Val(Text17) Mod Val(Text18) End If If Val(Text49) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text49.Text) <> 0 Then Text19.Text = Val(Text18) Text20.Text = Val(Text49) Text50.Text = Val(Text19) Mod Val(Text20)
Universitas Sumatera Utara
End If If Val(Text50) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text50.Text) <> 0 Then Text21.Text = Val(Text20) Text22.Text = Val(Text50) Text51.Text = Val(Text21) Mod Val(Text22) End If If Val(Text51) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text51.Text) <> 0 Then Text23.Text = Val(Text22) Text24.Text = Val(Text51) Text52.Text = Val(Text23) Mod Val(Text24) End If If Val(Text52) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text52.Text) <> 0 Then Text25.Text = Val(Text24) Text26.Text = Val(Text52) Text53.Text = Val(Text25) Mod Val(Text26) End If If Val(Text53) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text53.Text) <> 0 Then Text27.Text = Val(Text26) Text28.Text = Val(Text53) Text54.Text = Val(Text27) Mod Val(Text28) End If
Universitas Sumatera Utara
If Val(Text54) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text54.Text) <> 0 Then Text29.Text = Val(Text28) Text30.Text = Val(Text54) Text55.Text = Val(Text29) Mod Val(Text30) End If If Val(Text55) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text55.Text) <> 0 Then Text31.Text = Val(Text30) Text32.Text = Val(Text55) Text56.Text = Val(Text31) Mod Val(Text32) End If If Val(Text56) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If If Val(Text56.Text) <> 0 Then Text33.Text = Val(Text32) Text34.Text = Val(Text56) Text57.Text = Val(Text33) Mod Val(Text34) End If If Val(Text57) = 1 Then Text100 = Val(Text1) Text200 = Val(Text2) Text300 = 1 End If End Sub Sub Clear() Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = ""
Universitas Sumatera Utara
Text7.Text = "" Text8.Text = "" Text9.Text = "" Text10.Text = "" Text11.Text = "" Text12.Text = "" Text13.Text = "" Text14.Text = "" Text15.Text = "" Text16.Text = "" Text17.Text = "" Text18.Text = "" Text19.Text = "" Text20.Text = "" Text21.Text = "" Text22.Text = "" Text23.Text = "" Text24.Text = "" Text25.Text = "" Text26.Text = "" Text27.Text = "" Text28.Text = "" Text29.Text = "" Text30.Text = "" Text31.Text = "" Text32.Text = "" Text33.Text = "" Text34.Text = "" Text41.Text = "" Text42.Text = "" Text43.Text = "" Text44.Text = "" Text45.Text = "" Text46.Text = "" Text47.Text = "" Text48.Text = "" Text49.Text = "" Text50.Text = "" Text51.Text = "" Text52.Text = "" Text53.Text = "" Text54.Text = "" Text55.Text = "" Text56.Text = "" Text57.Text = "" Text100.Text = "" Text200.Text = ""
Universitas Sumatera Utara
Text300.Text = "" txt_nilai_e.Text = "" End Sub Private Sub txt_kunci_p_Change() txt_nilai_n.Text = 0 txt_totient.Text = 0 txt_nilai_e.Text = 0 txt_nilai_d.Text = 0 txt_chiper1.Text = "" pb_kunci_q.SetFocus End Sub Private Sub txt_kunci_q_Change() txt_nilai_n.Text = 0 txt_totient.Text = 0 txt_nilai_e.Text = 0 txt_nilai_d.Text = 0 txt_chiper1.Text = "" pb_hitung_n.SetFocus End Sub Private Sub txt_nilai_n_Change() txt_totient.Text = 0 txt_nilai_e.Text = 0 txt_nilai_d.Text = 0 txt_chiper1.Text = "" pb_hitung_totient.SetFocus End Sub Private Sub txt_totient_Change() Clear Text100.Text = Val(txt_totient.Text) Text1.Text = Val(txt_totient.Text) Text2.Text = 2 Text61.Text = 1 Text62.Text = 1 Text63.Text = 0 Text64.Text = 0 txt_nilai_e.Text = 0 txt_nilai_d.Text = 0 txt_chiper1.Text = "" pb_kunci_e.SetFocus End Sub Private Sub txt_nilai_e_Change() Text63.Text = Val(Text100) Text64.Text = Val(txt_nilai_e) txt_nilai_d.Text = 0
Universitas Sumatera Utara
txt_chiper1.Text = "" pb_kunci_d.SetFocus End Sub Private Sub txt_nilai_d_Change() txt_chiper1.Text = "" txt_plain1.SetFocus End Sub Private Sub txt_plain1_Change() txt_chiper1.Text = "" End Sub Private Sub Timer1_Timer() If HP = 0 Then lbl_header.Visible = True HP = 1 Else lbl_header.Visible = False HP = 0 End If End Sub Private Sub Timer2_Timer() n=n+1 Me.lbl_group.Caption = Left(Pemberitahuan, n) If n > Len(Pemberitahuan) Then n = 0 End Sub Private Sub Timer3_Timer() If HP = 0 Then l1.ForeColor = vbBlue l2.ForeColor = vbRed HP = 1 Else l1.ForeColor = vbRed l2.ForeColor = vbBlue HP = 0 End If End Sub Private Sub pb_keluar_Click() Unload Me End Sub Public Sub HanyaAngka(ByRef KeyAscii As Integer) If ((KeyAscii < 48 And KeyAscii <> 8) Or KeyAscii > 57) Then KeyAscii = 0 End If
Universitas Sumatera Utara
End Sub Private Sub txt_kunci_p_KeyPress(KeyAscii As Integer) HanyaAngka KeyAscii End Sub Private Sub txt_kunci_q_KeyPress(KeyAscii As Integer) HanyaAngka KeyAscii End Sub Form Dekripsi Dim PH As Integer Dim HP As Integer Dim Pemberitahuan Dim n As Byte Private Sub Form_Load() Pemberitahuan = " Untuk melakukan proses dekripsi pesan, terlebih dahulu masukkan nilai-nilai kunci untuk proses dekripsi, dan selanjutnya klick button proses jika chipertextnya sudah dientry.! " End Sub Private Sub lbl_header_Click() End Sub Private Sub pb_dekripsi_Click() If txt_nilai_d2.Text = 0 Then MsgBox "Nilai kunci (d) = 0" & vbCrLf & _ "Tentukan nilai kunci (d) untuk dapat melakukan proses dekripsi!", vbExclamation, "Nilai Kosong!" txt_nilai_d2.SetFocus Exit Sub End If If nilai_n.Text = 0 Then MsgBox "Nilai N = 0" & vbCrLf & _ "Tentukan nilai N untuk dapat melakukan proses dekripsi!", vbExclamation, "Nilai Kosong!" nilai_n.SetFocus Exit Sub End If If txt_nilai_d2.Text > 0 Then txt_plain2.Text = txt_simpan.Text End If If nilai_n.Text > 0 Then
Universitas Sumatera Utara
txt_plain2.Text = txt_simpan.Text End If End Sub Private Sub pb_hapus_Click() txt_chiper2.Text = "" txt_nilai_d2.Text = 0 txt_plain2.Text = "" nilai_n.Text = 0 End Sub Private Sub pb_keluar_Click() Unload Me End Sub Private Sub Timer1_Timer() If HP = 0 Then lbl_header.Visible = True HP = 1 Else lbl_header.Visible = False HP = 0 End If End Sub Private Sub Timer2_Timer() n=n+1 Me.lbl_group.Caption = Left(Pemberitahuan, n) If n > Len(Pemberitahuan) Then n = 0 End Sub Private Sub Timer3_Timer() If HP = 0 Then l1.ForeColor = vbBlue l2.ForeColor = vbRed HP = 1 Else l1.ForeColor = vbRed l2.ForeColor = vbBlue HP = 0 End If End Sub
Universitas Sumatera Utara