Prepared by Agung Julisman
• Definition Simple substitution
• Caesar cipher
• Algorithm
• Demo
prepared by Agung Julisman
• Substitution of single letters separately—simple
substitution—can be demonstrated by writing out the
alphabet in some order to represent the substitution. This
is termed a substitution alphabet. The cipher alphabet
may be shifted or reversed (creating the Caesar and
Atbash ciphers, respectively)
prepared by Agung Julisman
• The encryption step performed by a Caesar cipher is
often incorporated as part of more complex schemes,
such as the Vigenère cipher, and still has modern
application in the ROT13 system. As with all single
alphabet substitution ciphers, the Caesar cipher is easily
broken and in modern practice offers essentially no
communication security.
prepared by Agung Julisman
• for($i = 0; $i < strlen($str); $i++){
• //ord function in php char to ascii
• $code = ord($str[$i]) + $rot;
• // check function if code ascii > 90
• if ($code > 90) {
• $code = ($code - 90) + 64;
• }
• //chr function in php ascii to char
• echo chr($code);
• }
prepared by Agung Julisman
• <html>
• <head>
• <title>Fungsi terbilang</title>
• </head>
• <body>
• <form action="terbilang.php" method="post">
• Masukkan angka: <input type="text" value="" name="angka">
• <input type="submit" value="Send">
• </form>
• <pre>
• <?php
• $angka = isset($_POST['angka']) ? $_POST['angka'] : "0";
• if ($angka)
• {
• echo number_format($angka, 0) . "<br>";
• echo ucwords(Terbilang($angka));
• }
• ?>
• </pre>
• </body>
• </html>
• <?php
• function Terbilang($x)
• {
• $abil = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
• if ($x < 12)
• return " " . $abil[$x];
• elseif ($x < 20)
• return Terbilang($x - 10) . "belas";
• elseif ($x < 100)
• return Terbilang($x / 10) . " puluh" . Terbilang($x % 10);
• elseif ($x < 200)
• return " seratus" . Terbilang($x - 100);
• elseif ($x < 1000)
• return Terbilang($x / 100) . " ratus" . Terbilang($x % 100);
• elseif ($x < 2000)
• return " seribu" . Terbilang($x - 1000);
• elseif ($x < 1000000)
• return Terbilang($x / 1000) . " ribu" . Terbilang($x % 1000);
• elseif ($x < 1000000000)
• return Terbilang($x / 1000000) . " juta" . Terbilang($x % 1000000);
• }
• ?>
prepared by Agung Julisman

Substitution Cipher

  • 1.
  • 2.
    • Definition Simplesubstitution • Caesar cipher • Algorithm • Demo prepared by Agung Julisman
  • 3.
    • Substitution ofsingle letters separately—simple substitution—can be demonstrated by writing out the alphabet in some order to represent the substitution. This is termed a substitution alphabet. The cipher alphabet may be shifted or reversed (creating the Caesar and Atbash ciphers, respectively) prepared by Agung Julisman
  • 4.
    • The encryptionstep performed by a Caesar cipher is often incorporated as part of more complex schemes, such as the Vigenère cipher, and still has modern application in the ROT13 system. As with all single alphabet substitution ciphers, the Caesar cipher is easily broken and in modern practice offers essentially no communication security. prepared by Agung Julisman
  • 5.
    • for($i =0; $i < strlen($str); $i++){ • //ord function in php char to ascii • $code = ord($str[$i]) + $rot; • // check function if code ascii > 90 • if ($code > 90) { • $code = ($code - 90) + 64; • } • //chr function in php ascii to char • echo chr($code); • } prepared by Agung Julisman
  • 6.
    • <html> • <head> •<title>Fungsi terbilang</title> • </head> • <body> • <form action="terbilang.php" method="post"> • Masukkan angka: <input type="text" value="" name="angka"> • <input type="submit" value="Send"> • </form> • <pre> • <?php • $angka = isset($_POST['angka']) ? $_POST['angka'] : "0"; • if ($angka) • { • echo number_format($angka, 0) . "<br>"; • echo ucwords(Terbilang($angka)); • } • ?> • </pre> • </body> • </html> • <?php • function Terbilang($x) • { • $abil = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas"); • if ($x < 12) • return " " . $abil[$x]; • elseif ($x < 20) • return Terbilang($x - 10) . "belas"; • elseif ($x < 100) • return Terbilang($x / 10) . " puluh" . Terbilang($x % 10); • elseif ($x < 200) • return " seratus" . Terbilang($x - 100); • elseif ($x < 1000) • return Terbilang($x / 100) . " ratus" . Terbilang($x % 100); • elseif ($x < 2000) • return " seribu" . Terbilang($x - 1000); • elseif ($x < 1000000) • return Terbilang($x / 1000) . " ribu" . Terbilang($x % 1000); • elseif ($x < 1000000000) • return Terbilang($x / 1000000) . " juta" . Terbilang($x % 1000000); • } • ?> prepared by Agung Julisman