-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
94 lines (83 loc) · 3.96 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
include 'control.php';
?>
<html>
<head>
<title>Cipher Ease</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
</head>
<body>
<div class="h-100 d-flex justify-content-center align-items-center">
<form action="<?=basename($_SERVER["PHP_SELF"])?>" method="POST">
<div class="row">
<div class="col-md-12">
<h2>Cipher with Ease</h2>
</div>
</div>
<div class="row" style="padding: 10px 0 0;">
<div class="col-md-12">
<label>Input: </label>
<input type="text" name="input" class="form-control" value="<?php echo $_POST["input"] ?? ""; ?>">
</div>
<div class="col-md-12">
<label style="padding: 10px 0 0;">Key: </label>
<input type="text" name="key" class="form-control" value="<?php echo $_POST["key"] ?? ""; ?>">
</div>
</div>
<div class="row" style="padding: 30px 0 0;">
<div class="col-md-6">
<select name="choiceCipher" class="form-control">
<option value="caesar"
<?php
if (isset($_POST["choiceCipher"])) {
if ($_POST["choiceCipher"] == "caesar") {
echo "selected";
}
}
?>
>Caesar</option>
<option value="vigenere"
<?php
if (isset($_POST["choiceCipher"])) {
if ($_POST["choiceCipher"] == "vigenere") {
echo "selected";
}
}
?>
>Vigenère</option>
<option value="columnar"
<?php
if (isset($_POST["choiceCipher"])) {
if ($_POST["choiceCipher"] == "columnar") {
echo "selected";
}
}
?>
>Columnar</option>
</select>
</div>
<div class="col-md-3">
<input type="submit" name="encrypt" class="btn btn-primary" value="Encrypt">
</div>
<div class="col-md-3">
<input type="submit" name="decrypt" class="btn btn-primary" value="Decrypt">
</div>
</div>
<div class="row" style="padding: 20px 0 0;">
<div class="col-md-12">
<label>Output: </label>
<textarea class="form-control" style="resize: none;" readonly><?php
if (isset($_POST["encrypt"]) || isset($_POST["decrypt"])) {
$choiceCrypt = isset($_POST["encrypt"]) ? "encrypt" : "decrypt";
$input = $_POST["input"];
$key = $_POST["key"];
$choiceCipher = $_POST["choiceCipher"];
echo encryptChoice($choiceCipher, $input, $key, $choiceCrypt);
}
?></textarea>
</div>
</div>
</form>
</div>
</body>
</html>