You are on page 1of 8

Kriptografi Klasik

Transpormasi dan Subtitusi Ciphers


(Caesar & Horizontal)

Transposition Ciphers
Plainteks:

ABCDEFGHIJKLMNOPQRSTUVWXZY
A B D E F H I J L M N P Q R T U V X Y Z

Ciperteks:

AEIMQUYBDFHJLNPRTVXZCGKOSW

Tampilan Program

Kode Program
1. 2. 3. 1. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. Dim x1(1 To 50) As String Dim x2(1 To 50) As String Dim x3(1 To 50) As String Private Sub Command1_Click() j=0 naik = True For i = 1 To Len(Text1.Text) huruf = Mid(Text1.Text, i, 1) j=j+1 If j > 3 Then If naik = True Then naik = False j=2 End If Else j=j-1 If j < 1 Then naik = True j=2 End If End If
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 1. 2. 3. 1. 2. 3. 1. 2. 3. 4. If j = 1 Then x1(i) = huruf End If If j = 2 Then x2(i) = huruf End If If j = 3 Then x3(i) = huruf End If Next i For i = 1 To Len(Text1.Text) Text2.Text = Text2.Text & x1(i) Next i For i = 1 To Len(Text1.Text) Text2.Text = Text2.Text & x2(i) Next i For i = 1 To Len(Text1.Text) Text2.Text = Text2.Text & x3(i) Next i End Sub

Cipher Substitusi
Caesar Cipher Pergeseran huruf sejauh 3 huruf (kunci enkrip dan deskripsi). Cipherteks: C=E(P)=(P+3) mod 26 Plainteks: P=D(P)=(C-3) mod 26

Keterangan Cipherteks Caesar


P1=A=0 C1=(0+3) mod 26=3=D
P2=B=1 C2=(1+3) mod 26=4=E P3=C=2 C3=(2+3) mod 26=5=F Dst...

Caesar Ciphers

Kode Program
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 1. Private Sub Command3_Click() Counter = 1 For i = 1 To Len(Text1.Text) If Asc(Mid(Text1.Text, i, 1)) <> 32 Then If Asc(Mid(Text1.Text, i, 1)) <= 90 Then posisi = Asc(Mid(Text1.Text, i, 1)) - 65 rumus = (posisi + 3) Mod 26 If Counter Mod 5 = 0 Then Text2.Text = Text2.Text & " " Else Text2.Text = Text2.Text & Chr(65 + rumus) End If Else posisi = Asc(Mid(Text1.Text, i, 1)) - 97 rumus = (posisi + 3) Mod 26 If Counter Mod 5 = 0 Then Text2.Text = Text2.Text & " " Else Text2.Text = Text2.Text & Chr(97 + rumus) End If End If Counter = Counter + 1 End If Next i End Sub

You might also like