diff --git a/kripto-ti/tugas-1/check.php b/kripto-ti/tugas-1/check.php new file mode 100644 index 0000000..06d45ea --- /dev/null +++ b/kripto-ti/tugas-1/check.php @@ -0,0 +1,109 @@ +\n"; + echo "\n"; + echo "\n"; + echo "Willy Sudiarto Raharjo - Tugas 2 Keamanan Komputer - Semester Gasal 2016/2017\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "Hasil Enkripsi: \n"; + echo "
\n"; + $resultingCipherText = ""; + echo "plaintext: $inputPlainText
"; + echo "kunci: $inputKey
"; + /* + /* Pergeseran sebanyak panjang kunci + */ + for ($i = 0; $i < $keyLength; $i++) + { + /* + /* Jika loop pertama, gunakan input awal + /* Jika bukan loop pertama, gunakan hasil perhitungan sebelumnya + */ + if ($i == 0) + { + $originalPlainText = $inputPlainText; + } + else + { + $originalPlainText = $resultingCipherText; + } + + /* + /* Jumlah pergeseran dari karakter ke-i dari kunci + /* Hasilnya dikurangi 97 karena karakter a kode ASCInya 97 + /* Kita ingin a = 0, b = 1, c = 2, dst + */ + $numberOfMovement = ord($inputKey[$i]) - 97; + + echo "Karakter ke-" . ($i+1) . " kunci - "; + + /* + /* Pergeseran sebanyak panjang plaintext + */ + for ($j = 0; $j < $plainTextLength; $j++) + { + /* + /* Algoritma: + /* 1. Ambil kode ASCII dari teks menggunakan fungsi ord + /* 2. Konversi ke bilangan 0 - 25 dengan mengurangi 97 + /* 3. Tambahkan jumlah pergeseran dari karakter ke-i dari kunci + /* 4. Pastikan hasilnya diantara 0-25 dengan cara modulus 26 + /* 5. Kembalikan hasilnya ke karakter ASCII dengan fungsi chr + */ + $originalPlainText[$j] = chr((((ord($originalPlainText[$j]) - 97) + $numberOfMovement) % 26) + 97); + echo $originalPlainText[$j]; + } + echo "
\n"; + /* + /* Simpan hasilnya ke variabel resultingCipherText untuk nilai awal loop berikutnya + */ + $resultingCipherText = $originalPlainText; + } + echo "ciphertext: $resultingCipherText"; + echo "
\n"; + echo ":: Kembali ke halaman input ::\n"; + echo "
\n"; + echo "
\n"; + echo "Willy Sudiarto Raharjo\n"; + echo "
\n"; + echo "\n"; + echo "\n"; +} +else // Jika ternyata diakses melalui metode GET (kemungkinan besar pemanggilan langsung) +{ + header("location:index.php"); // Redirect ke halaman input + exit; // hanya memastikan bahwa tidak menjalankan perintah lain +} +?> diff --git a/kripto-ti/tugas-1/functions.php b/kripto-ti/tugas-1/functions.php new file mode 100755 index 0000000..955c306 --- /dev/null +++ b/kripto-ti/tugas-1/functions.php @@ -0,0 +1,29 @@ +\n"; + echo "\n"; + echo "\n"; + echo "Willy Sudiarto Raharjo - Tugas 2 Keamanan Komputer - Semester Gasal 2016/2017\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "Kesalahan\n"; + echo "
\n"; + echo "
\n"; + echo $string . "\n"; + echo "
\n"; + echo "
\n"; + echo ":: Kembali ke halaman input ::\n"; + echo "
\n"; + echo "
\n"; + echo "Willy Sudiarto Raharjo\n"; + echo "
\n"; + echo "\n"; + echo "\n"; +} diff --git a/kripto-ti/tugas-1/index.css b/kripto-ti/tugas-1/index.css new file mode 100755 index 0000000..d170e10 --- /dev/null +++ b/kripto-ti/tugas-1/index.css @@ -0,0 +1,112 @@ +body { +margin: 0.5em 0.5em; +font-family: Serif; +font-size: 12pt; +text-align: justify; +background-color: #FFF; +color: #000; +} + +.Title, .Info, .Result-Title { +border-top: 2px solid #000; +border-bottom: 2px solid #000; +text-align: center; +font-weight: bold; +font-size: 14pt; +margin-bottom: 1em; +background: #d8e4f1; +} + +form { +font-weight: bold; +font-size: 2em; +} + +textarea:focus { +background: #C4E7F4; +} + +input { +margin-top: 1em; +} + +.Notes-Title { +color: #F00; +font-size: 1.33em; +} + +.Notes { +line-height: 1.33em; +word-spacing: 1px; +} + +li { +font-weight: bold; +line-height: 1.5em; +} + +.Link { +margin-top: 1em; +margin-bottom: 2em; +text-align: center; +font-family: Sans-Serif; +font-weight: bold; +font-size : 14px; +} + +p { +margin: 0; +padding-top: 0.5em; +font-weight: bold; +} + +div.result { +padding-bottom: 0.5em; +border-bottom: 2px solid #558864; +} + +a { +text-decoration:none; +color: #4064FE; +} + +a.url:link { +color: #4064FE; +} + +a.url:visited { +color: #4064FE; +} + +a.url:hover { +text-decoration: underline; +color: #4064FE; +} + +a.url:active { +text-decoration: underline; +color: #4064FE; +} + +.Error-Title { +border-top: 2px solid #F00; +border-bottom: 2px solid #F00; +text-align: center; +font-weight: bold; +font-size: 14pt; +color: #FFF; +margin-bottom: 1em; +background: #F00; +} + +.Error-Notes { +text-align: center; +color: #F00; +font-size: 16pt; +} + +.LastUpdate { +font-size: 80%; +margin-top: 1em; +text-align: right; +} diff --git a/kripto-ti/tugas-1/index.php b/kripto-ti/tugas-1/index.php new file mode 100644 index 0000000..81faf88 --- /dev/null +++ b/kripto-ti/tugas-1/index.php @@ -0,0 +1,89 @@ + + + +Willy Sudiarto Raharjo - Tugas 1 Kriptografi - Semester Gasal 2023/2024 + + + + + +
+TUGAS 1 KRIPTOGRAFI SEMESTER GASAL 2023/2024 +
+

Anda diminta untuk membuat sebuah program yang bisa menerima input berupa plaintext dan mengubahnya menjadi ciphertext dengan ketentuan sebagai berikut:

+
    +
  1. Input berupa plain ASCII huruf kecil (a-z) tanpa ada angka dan spasi
  2. +
  3. Seluruh isi teks akan diproses per karakter kunci + +
  4. +
+Contoh: +
+Plaintext: aku
+Kunci: diam
+Output:
+Karakter ke-1 kunci: dnx (d)
+Karakter ke-2 kunci: lvf (i)
+Karakter ke-3 kunci: lvf (a)
+Karakter ke-4 kunci: xhr (m)
+ciphertext: xhr
+
+Input Plaintext:
+
+Input Kunci:
+
+ +
+
+Catatan : +
+
+
    +
  1. Input boleh huruf besar/kecil
  2. +
  3. Input hanya berupa alphabet
  4. +
  5. Input tidak boleh mengandung spasi
  6. +
+
+

+ +

+
+Willy Sudiarto Raharjo +
+ +