-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaesar1.php
More file actions
92 lines (91 loc) · 3.06 KB
/
caesar1.php
File metadata and controls
92 lines (91 loc) · 3.06 KB
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
<?php
##
## This code is licensed under the GPL-v3
## Belongs to the "encrypt" system that can be found here:
## https://github.com/CaeSpock/encrypt
## Questions and suggestions are always welcomed. Send me an E-Mail at: CAnibarro<at>WhiteSith<dot>com
##
// Cesar cipher Type 1
if ($enckey==0 || is_null($enckey)) {
echo "<div class=\"alert alert-danger\">\n";
echo "<strong>$l_alert!</strong> $l_noksent\n";
echo "</div>\n";
} else {
if ($phrase == "" or is_null($phrase)) {
echo "<div class=\"alert alert-danger\">\n";
echo "<strong>$l_alert!</strong> $l_nopsent\n";
echo "</div>\n";
} else {
echo "<div class=\"table-responsive\">\n";
echo "<table class=\"table table-sm\">\n";
echo "<tr>\n";
echo " <td class=\"table-dark text-right\">$l_type:</td>\n";
echo " <td>$l_caesar1 - K=$enckey</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td class=\"table-dark text-right\">$l_alphabet:</td>\n";
echo " <td><pre>";
for ($i=65; $i<=90; $i++) {
echo chr($i);
}
echo "</pre></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td class=\"table-dark text-right\">$l_newalphabet:</td>\n";
echo " <td><pre>";
for ($i=65; $i<=90; $i++) {
$position=$i;
if ($i>(90-$enckey)) { $position=($i+$enckey-(26+$enckey)); }
$letter=$position+$enckey;
echo chr($letter);
}
echo "</pre></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td class=\"bg-warning text-right\"><strong>$l_phrase:</strong></td>\n";
echo " <td><pre>$phrase</pre></td>";
echo "</tr>\n";
echo "<tr>\n";
echo " <td class=\"bg-success text-right\"><strong>$l_newphrase:</strong></td>\n";
echo " <td><pre>";
$counter=0;
while ($counter < strlen($phrase)) {
$position = ord($phrase[$counter]);
if ($position >=65 and $position<=90) {
if ($position > (90-$enckey)) {
$position= $position+$enckey-(26);
} else {
$position = $position + $enckey;
}
}
echo chr($position);
$counter++;
}
echo "</pre></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td class=\"bg-danger text-right\"><strong>$l_inverted:</strong></td>\n";
echo " <td><pre>";
$counter=0;
while ($counter < strlen($phrase)) {
$position = ord($phrase[$counter]);
if ($position >=65 and $position<=90) {
if ($position < (65+$enckey)) {
$position = $position - $enckey +26;
} else {
$position = $position - $enckey;
}
}
echo chr($position);
$counter++;
}
echo "</pre></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
}
}
echo "<br /><br />";
echo "<div class=\"text text-center\">\n";
echo "<a href=\"$phpself\" class=\"btn btn-secondary\" role=\"button\">$l_goback</a>\n";
echo "</div>";