-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathenc_dec.php
42 lines (40 loc) · 1.01 KB
/
enc_dec.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
<?php
$errorKey = $errorData = $dataSet = $result = $showKey = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$operation = $_POST['operation'];
$dataSet = true;
if(empty($_POST['key'])){
$dataSet = false;
$errorKey = "* You have to enter at least 1 symbol! ";
$key = "";
echo "<style>.errorMsg1{display:block;}</style>";
}else{
$key = $_POST['key'];
}
if(empty($_POST['data'])){
$dataSet = false;
$errorData = "* You have to enter a data for encryption!";
$data = "";
echo "<style>.errorMsg2{display:block;}</style>";
}else{
$data = $_POST['data'];
}
if (!empty($_POST['encBit'])){
$encBit = $_POST['encBit'];
}
if ($dataSet === true) {
$aes = new AES($data, $key, $encBit);
if ($operation == "encrypt" && $dataSet === true) {
// encryption code here
$enc = $aes->encrypt();
$aes->setData($enc);
$result = $enc;
$showKey = $key;
} elseif ($operation == "decrypt" && $dataSet === true) {
// decription code here
$dec = $aes->decrypt();
$result = $dec;
}
}
}
?>