2
0

Compare commits

...

3 Commits

Author SHA1 Message Date
Schuledaniel
11a260008e add stuff of 16. Jan 26 2026-01-16 08:15:01 +01:00
Schuledaniel
ec20b28fc4 Update README.md 2026-01-14 14:17:15 +01:00
Schuledaniel
19c2ba6e1f task of LBT3 2026-01-14 14:04:25 +01:00
3 changed files with 143 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
<?php
// WIP
// Caesar-Chiffre Funktion
function caesar($text, $shift) {
$textArr = str_split($text, 1);
// definition is gewohnheit aus angular
$textAscii = [];
$resAscii = [];
$resArr = [];
for($i = 0; $i > 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 "<pre> $yo </pre>";
$yo = print_r($textAscii);
echo "<pre> $yo </pre>";
$yo = print_r($resAscii);
echo "<pre> $yo </pre>";
$yo = print_r($resArr);
echo "<pre> $yo </pre>";
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);
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Caesar Chiffre</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f4f4f4;
padding: 30px;
}
.box {
background: white;
padding: 20px;
max-width: 500px;
margin: auto;
border-radius: 8px;
}
textarea, input {
width: 100%;
padding: 10px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
margin-right: 10px;
}
label{
display: block;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="box">
<h2>Caesar Chiffre</h2>
<form method="post">
<label for="text">Nachricht:</label>
<textarea name="text" rows="4"><?= htmlspecialchars($text) ?></textarea>
<label>Verschiebung:</label>
<input type="number" name="shift" min = 1 max = 26 value="<?= htmlspecialchars($shift) ?>">
<!--<input type="number" name="shift" value="<?= htmlspecialchars($shift) ?>">-->
<button type="submit" name="encrypt">Verschlüsseln</button>
<button type="submit" name="decrypt">Entschlüsseln</button>
<label for="result"> Verschlüsselte Nachricht:</label>
<textarea name="result" rows="4" readonly><?= htmlspecialchars($output ?: $text) ?></textarea>
</form>
</div>
</body>
</html>

View File

@@ -8,6 +8,12 @@ Wichtige Informationen
- Stundenplan - [Link](https://wvss-mannheim.webuntis.com/WebUntis/?school=wvss-mannheim#/basic/timetablePublic/class?entityId=2583)
## 16-01-26 - PHP
- Modulo
## 14-01-26 - PHP
- Kryptologie (LBT3)
## 12-12-25 - PHP (SQL)
- Aufgabe von gester überarbeitet
- Unterrichts Projekt:

26
Zweites Jahr/modulo.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
$ergebnis = (int)(7/2);
echo $ergebnis."<br>";
$ergebnis = 7%3;
echo "Restwert: ".$ergebnis."<br>";
// Ist ZAhl gerade?
$zahl = 5;
if($zahl % 2 == 0)echo "$zahl is gerade.<br>";
else echo "$zahl ist ungerade.<br>";
// LEtze Zahl einer ZAhl ermitteln
$zahl = 123;
echo $zahl % 10; // In Zahl steht 3 wenn $zahl%=3
echo "<br>".$zahl."<br>";
echo (int)($zahl/10); // 123 -> 12