Algoritma Kriptografi Klasik
Transcript of Algoritma Kriptografi Klasik
Pendahuluan
Algoritma kriptografi klasik berbasis karakter Menggunakan pena dan kertas saja, belum
ada komputer Termasuk ke dalam kriptografi kunci-simetri Algoritma kriptografi klasik:
– Cipher Substitusi (Substitution Ciphers)– Cipher Transposisi (Transposition Ciphers)
Algoritma kriptografi klasik berbasis karakter Menggunakan pena dan kertas saja, belum
ada komputer Termasuk ke dalam kriptografi kunci-simetri Algoritma kriptografi klasik:
– Cipher Substitusi (Substitution Ciphers)– Cipher Transposisi (Transposition Ciphers)
Basic Terms
Plaintext– The original message
Ciphertext– The coded message
Cipher– Algorithm for transforming between
plaintext and ciphertext
Key– Info used in cipher known only to
sender/receiver
Encipher / Ecnrypt– Converting plaintext to ciphertext
Decipher / Decrypt– Converting ciphertext back to plaintext
Cryptography– Study of encryption principles/methods
Cryptanalysis– Study of principles/methods of
dechipering ciphertext without knowingthe key
Cryptology– The field study of both cryptography
and cryptanalysis
Plaintext– The original message
Ciphertext– The coded message
Cipher– Algorithm for transforming between
plaintext and ciphertext
Key– Info used in cipher known only to
sender/receiver
Encipher / Ecnrypt– Converting plaintext to ciphertext
Decipher / Decrypt– Converting ciphertext back to plaintext
Cryptography– Study of encryption principles/methods
Cryptanalysis– Study of principles/methods of
dechipering ciphertext without knowingthe key
Cryptology– The field study of both cryptography
and cryptanalysis
Symettric-Key Cryptogaphy
Also known as
• Private KeyCryptography
• Secret KeyCryptography
Also known as
• Private KeyCryptography
• Secret KeyCryptography
0 1 2 3 4 5 6 7 8 9 10A B C D E F G H I J K
11 12 13 14 15 16 17 18 19 20L M N O P Q R S T U
21 22 23 24 25V W X Y Z
0 1 2 3 4 5 6 7 8 9 10A B C D E F G H I J K
11 12 13 14 15 16 17 18 19 20L M N O P Q R S T U
21 22 23 24 25V W X Y Z
1. Cipher Substitusi
Monoalfabet : setiap karakter chipertextmenggantikan satu macam karakter plaintext
Polyalfabet : setiap karakter chipertextmenggantikan lebih dari satu macam karakterplaintext
Monograf /unilateral: satu enkripsi dilakukanterhadap satu karakter plaintext
Polygraf /multilateral: satu enkripsi dilakukanterhadap lebih dari satu karakter plaintext
Monoalfabet : setiap karakter chipertextmenggantikan satu macam karakter plaintext
Polyalfabet : setiap karakter chipertextmenggantikan lebih dari satu macam karakterplaintext
Monograf /unilateral: satu enkripsi dilakukanterhadap satu karakter plaintext
Polygraf /multilateral: satu enkripsi dilakukanterhadap lebih dari satu karakter plaintext
1. Cipher Substitusi - Caesar Cipher
Tiap huruf alfabet digeser 3 huruf ke kanan
pi : A B C D E F G H I J K L M N O P Q R S T U V W X Y Zci : D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Contoh:Plainteks: AWASI ASTERIX DAN TEMANNYA OBELIXCipherteks: DZDVL DVWHULA GDQ WHPDQQBA REHOLA
Tiap huruf alfabet digeser 3 huruf ke kanan
pi : A B C D E F G H I J K L M N O P Q R S T U V W X Y Zci : D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Contoh:Plainteks: AWASI ASTERIX DAN TEMANNYA OBELIXCipherteks: DZDVL DVWHULA GDQ WHPDQQBA REHOLA
Caesar Cipher
Using K=3
Each letter will be replaced by the3rd letter after it.
A DB E…Z C
Using K=3
Each letter will be replaced by the3rd letter after it.
A DB E…Z C
Caesar Cipher Example
K = 3 Plaintext letter: ABCDEF … XYZ Ciphertext letter: DEFGHI … ABC
Plaintext sample– TREATY IMPOSSIBLE
Ciphertext result– WUHDWB LPSRVVLEOH
K = 3 Plaintext letter: ABCDEF … XYZ Ciphertext letter: DEFGHI … ABC
Plaintext sample– TREATY IMPOSSIBLE
Ciphertext result– WUHDWB LPSRVVLEOH
1. Cipher Substitusi - Caesar Cipher
Dalam praktek, cipherteks dikelompokkan ke dalamkelompok n-huruf, misalnya kelompok 4-huruf:DZDV LDVW HULA GDQW HPDQ QBAR EHOL A
Atau membuang semua spasi:DZDVLDVWHULAGDQWHPDQQBAREHOLA
Tujuannya agar kriptanalisis menjadi lebih sulit
Dalam praktek, cipherteks dikelompokkan ke dalamkelompok n-huruf, misalnya kelompok 4-huruf:DZDV LDVW HULA GDQW HPDQ QBAR EHOL A
Atau membuang semua spasi:DZDVLDVWHULAGDQWHPDQQBAREHOLA
Tujuannya agar kriptanalisis menjadi lebih sulit
Caesar Cipher Math Formula
If we give number to each letter depends on its order, we canwrite a math formula for this algorithm as follow:
C = E(P) = (P+k) mod (26) P = D(C) = (C-k) mod (26)
Example, K=5– WAR STARTS TOMORROW
– 22 0 17 18 19 0 17 19 14 12 14 17 17 14 22
– 1 5 22 23 24 5 22 24 23 17 19 23 23 19 1
– BFW XYFWYX YTRTXXTB
If we give number to each letter depends on its order, we canwrite a math formula for this algorithm as follow:
C = E(P) = (P+k) mod (26) P = D(C) = (C-k) mod (26)
Example, K=5– WAR STARTS TOMORROW
– 22 0 17 18 19 0 17 19 14 12 14 17 17 14 22
– 1 5 22 23 24 5 22 24 23 17 19 23 23 19 1
– BFW XYFWYX YTRTXXTB
1. Cipher Substitusi - Vigènere Cipher
Termasuk ke dalam cipher abjad-majemuk(polyalpabetic substitution cipher ).
Algoritma tersebut baru dikenal luas 200 tahunkemudian yang oleh penemunya cipher tersebutkemudian dinamakan Vigènere Cipher.
Vigènere Cipher menggunakan BujursangkarVigènere untuk melakukan enkripsi.
Setiap baris di dalam bujursangkar menyatakanhuruf-huruf cipherteks yang diperoleh denganCaesar Cipher.
Termasuk ke dalam cipher abjad-majemuk(polyalpabetic substitution cipher ).
Algoritma tersebut baru dikenal luas 200 tahunkemudian yang oleh penemunya cipher tersebutkemudian dinamakan Vigènere Cipher.
Vigènere Cipher menggunakan BujursangkarVigènere untuk melakukan enkripsi.
Setiap baris di dalam bujursangkar menyatakanhuruf-huruf cipherteks yang diperoleh denganCaesar Cipher.
1. Cipher Substitusi - Vigènere CipherPlainteks
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a A B C D E F G H I J K L M N O P Q R S T U V W X Y Zb B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ac C D E F G H I J K L M N O P Q R S T U V W X Y Z A Bd D E F G H I J K L M N O P Q R S T U V W X Y Z A B Ce E F G H I J K L M N O P Q R S T U V W X Y Z A B C Df F G H I J K L M N O P Q R S T U V W X Y Z A B C D Eg G H I J K L M N O P Q R S T U V W X Y Z A B C D E Fh H I J K L M N O P Q R S T U V W X Y Z A B C D E F Gi I J K L M N O P Q R S T U V W X Y Z A B C D E F G Hj J K L M N O P Q R S T U V W X Y Z A B C D E F G H IK K L M N O P Q R S T U V W X Y Z A B C D E F G H I Jl L M N O P Q R S T U V W X Y Z A B C D E F G H I J Km M N O P Q R S T U V W X Y Z A B C D E F G H I J K Ln N O P Q R S T U V W X Y Z A B C D E F G H I J K L Mo O P Q R S T U V W X Y Z A B C D E F G H I J K L M Np P Q R S T U V W X Y Z A B C D E F G H I J K L M N Oq Q R S T U V W X Y Z A B C D E F G H I J K L M N O Pr R S T U V W X Y Z A B C D E F G H I J K L M N O P Qs S T U V W X Y Z A B C D E F G H I J K L M N O P Q Rt T U V W X Y Z A B C D E F G H I J K L M N O P Q R Su U V W X Y Z A B C D E F G H I J K L M N O P Q R S Tv V W X Y Z A B C D E F G H I J K L M N O P Q R S T Uw W X Y Z A B C D E F G H I J K L M N O P Q R S T U Vx X Y Z A B C D E F G H I J K L M N O P Q R S T U V Wy Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
Kunci
z Z A B C D E F G H I J K L M N O P Q R S T U V W X Y
Gambar 4.2 Bujursangkar Vigènere
Plainteks
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a A B C D E F G H I J K L M N O P Q R S T U V W X Y Zb B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ac C D E F G H I J K L M N O P Q R S T U V W X Y Z A Bd D E F G H I J K L M N O P Q R S T U V W X Y Z A B Ce E F G H I J K L M N O P Q R S T U V W X Y Z A B C Df F G H I J K L M N O P Q R S T U V W X Y Z A B C D Eg G H I J K L M N O P Q R S T U V W X Y Z A B C D E Fh H I J K L M N O P Q R S T U V W X Y Z A B C D E F Gi I J K L M N O P Q R S T U V W X Y Z A B C D E F G Hj J K L M N O P Q R S T U V W X Y Z A B C D E F G H IK K L M N O P Q R S T U V W X Y Z A B C D E F G H I Jl L M N O P Q R S T U V W X Y Z A B C D E F G H I J Km M N O P Q R S T U V W X Y Z A B C D E F G H I J K Ln N O P Q R S T U V W X Y Z A B C D E F G H I J K L Mo O P Q R S T U V W X Y Z A B C D E F G H I J K L M Np P Q R S T U V W X Y Z A B C D E F G H I J K L M N Oq Q R S T U V W X Y Z A B C D E F G H I J K L M N O Pr R S T U V W X Y Z A B C D E F G H I J K L M N O P Qs S T U V W X Y Z A B C D E F G H I J K L M N O P Q Rt T U V W X Y Z A B C D E F G H I J K L M N O P Q R Su U V W X Y Z A B C D E F G H I J K L M N O P Q R S Tv V W X Y Z A B C D E F G H I J K L M N O P Q R S T Uw W X Y Z A B C D E F G H I J K L M N O P Q R S T U Vx X Y Z A B C D E F G H I J K L M N O P Q R S T U V Wy Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
Kunci
z Z A B C D E F G H I J K L M N O P Q R S T U V W X Y
Gambar 4.2 Bujursangkar Vigènere
1. Cipher Substitusi - Vigènere Cipher
Contoh penerapan Vigènere Cipher :Plainteks : THIS PLAINTEXTKunci : sony sonysonysCipherteks : LVVQ HZNGFHRVL
Jika panjang kunci lebih pendek daripada panjang plainteks,maka kunci diulang secara periodik. Dalam hal ini Kunci“sony” diulang sebanyak panjang plaintext-nya
Pada dasarnya, setiap enkripsi huruf adalah Caesar cipherdengan kunci yang berbeda-beda.
e(‘T’) = (‘T’ + ‘s’) mod 26 = LT = 20 dan s= 19 (20+19)%26=13 Ld(‘V’) = (‘V’ - ‘n’) mod 26 = 21 – 13 = 8 I
Contoh penerapan Vigènere Cipher :Plainteks : THIS PLAINTEXTKunci : sony sonysonysCipherteks : LVVQ HZNGFHRVL
Jika panjang kunci lebih pendek daripada panjang plainteks,maka kunci diulang secara periodik. Dalam hal ini Kunci“sony” diulang sebanyak panjang plaintext-nya
Pada dasarnya, setiap enkripsi huruf adalah Caesar cipherdengan kunci yang berbeda-beda.
e(‘T’) = (‘T’ + ‘s’) mod 26 = LT = 20 dan s= 19 (20+19)%26=13 Ld(‘V’) = (‘V’ - ‘n’) mod 26 = 21 – 13 = 8 I
Cont.
Ganti huruf J (bila ada)dengan I
Tulis pesan dalampasangan huruf
Jangan sampai adapasangan huruf yang sama.Jika ada, sisipkan Zditengahnya
Jika jumlah huruf ganjil,tambahkan huruf Z di akhir
Ganti huruf J (bila ada)dengan I
Tulis pesan dalampasangan huruf
Jangan sampai adapasangan huruf yang sama.Jika ada, sisipkan Zditengahnya
Jika jumlah huruf ganjil,tambahkan huruf Z di akhir
2. Cipher Transposisi
Cipherteks diperoleh dengan mengubah posisi hurufdi dalam plainteks.
Dengan kata lain, algoritma ini melakukan transposeterhadap rangkaian huruf di dalam plainteks.
Nama lain untuk metode ini adalah permutasi,karena transpose setiap karakter di dalam teks samadengan mempermutasikan karakter-karaktertersebut.
Cipherteks diperoleh dengan mengubah posisi hurufdi dalam plainteks.
Dengan kata lain, algoritma ini melakukan transposeterhadap rangkaian huruf di dalam plainteks.
Nama lain untuk metode ini adalah permutasi,karena transpose setiap karakter di dalam teks samadengan mempermutasikan karakter-karaktertersebut.
2. Cipher Transposisi (Contoh)
Contoh: Misalkan plainteks adalahPOLITEKNIK ELEKTRONIKA NEGERI SURABAYA
Enkripsi:POLITEKNIKELEKTRONIKANEGERISURABAYA
Cipherteks: (baca secara vertikal)PNTNUOIRERLKOGAIENEBTLIRAEEKIYKKASAPNTN UOIR ERLK OGAI ENEB TLIR AEEK IYKK ASA
Contoh: Misalkan plainteks adalahPOLITEKNIK ELEKTRONIKA NEGERI SURABAYA
Enkripsi:POLITEKNIKELEKTRONIKANEGERISURABAYA
Cipherteks: (baca secara vertikal)PNTNUOIRERLKOGAIENEBTLIRAEEKIYKKASAPNTN UOIR ERLK OGAI ENEB TLIR AEEK IYKK ASA
Rail Fence Cipher
Write message letters out diagonally over anumber of rows, then read off cipher row by row
Example, using plaintext (k=2)– meet me after the toga party
Write message out as:m e m a t r h t g p r ye t e f e t e o a a t
Giving ciphertextMEMATRHTGPRYETEFETEOAAT
Write message letters out diagonally over anumber of rows, then read off cipher row by row
Example, using plaintext (k=2)– meet me after the toga party
Write message out as:m e m a t r h t g p r ye t e f e t e o a a t
Giving ciphertextMEMATRHTGPRYETEFETEOAAT
Columnar Transposition
The number of columns is the key information. To encipher: Plaintext is written horizontally in k
columns, and is then transcribed vertically columnby-column,
To decipher: Suppose that the length of theciphertext is n and the key is k. Then the letters willfill n DIV k full rows, and there will be one partial rowat the end with nMODk letters. Transcribing row-by-row will then yield the plaintext.
The number of columns is the key information. To encipher: Plaintext is written horizontally in k
columns, and is then transcribed vertically columnby-column,
To decipher: Suppose that the length of theciphertext is n and the key is k. Then the letters willfill n DIV k full rows, and there will be one partial rowat the end with nMODk letters. Transcribing row-by-row will then yield the plaintext.