-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
36 lines (26 loc) · 678 Bytes
/
Copy pathtest.php
File metadata and controls
36 lines (26 loc) · 678 Bytes
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
<?php
// $plain = $_POST['plain'];
// $chiper = $_POST['chiper'];
$plain = "aku ganteng opo ya";
$chiper = 7;
// Enkripsi caesar
$pisah = str_split($plain); //Pisah string jadi array
$encstr = " ";
for ($i=0; $i < count($pisah); $i++) {
$ascii = ord($pisah[$i]); //Convert ke ascii
$caesar = ($ascii + $chiper) % 256; //Rumus algoritma caesar
$encstr .= chr($caesar); //Convert lagi ke string
}
echo $encstr;
echo $ascii;
$anu = str_split($encstr);
$tampil = "";
for ($a=0; $a < count($anu); $a++) {
$convert = ord($anu[$a]);
$cesar = ($convert - $chiper) % 127;
$tampil .= chr($cesar);
}
echo "<br><br>";
echo $tampil;
// print_r($anu);
?>