diff --git a/Zweites Jahr/Kryptologie/caeser-verschluesselung.php b/Zweites Jahr/Kryptologie/caeser-verschluesselung.php new file mode 100644 index 0000000..dbea8e7 --- /dev/null +++ b/Zweites Jahr/Kryptologie/caeser-verschluesselung.php @@ -0,0 +1,111 @@ + count($textArr); $i++){ + // jeder buchstabe des textes wird zum array, + // in dessen ascii zeichen, $resAscii hinzugefügt + array_push($textAscii, ord($textArr[$i])); + // verschiebung + $resAscii[$i] =+ $shift; + // ascii buchstaben werden in ein wort gemacht + array_push($resArr, chr($resAscii[$i])); + } + // aus array ein wort machen + $result = implode("", $resArr); + + $yo = print_r($textArr); + echo "
 $yo 
"; + $yo = print_r($textAscii); + echo "
 $yo 
"; + $yo = print_r($resAscii); + echo "
 $yo 
"; + $yo = print_r($resArr); + echo "
 $yo 
"; + + return $result; +} + +// Formularverarbeitung +$output = ""; +$text = ""; +$shift = 0; +if ($_SERVER["REQUEST_METHOD"] === "POST") { + $text = $_POST["text"] ?? ""; + $shift = intval($_POST["shift"] ?? 0); + + if (isset($_POST["encrypt"])) { + $output = caesar($text, $shift); + } + + if (isset($_POST["decrypt"])) { + $output = caesar($text, -$shift); + } +} +?> + + + + + + Caesar Chiffre + + + + +
+

Caesar Chiffre

+ +
+ + + + + + + + + + + + +
+
+ + +