-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
75 lines (65 loc) · 2.14 KB
/
index.php
File metadata and controls
75 lines (65 loc) · 2.14 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
<?php
require_once 'RSA/RSA.php';
require_once 'config.php';
if (isset($_POST['submit'])){
$RSA = new RSA(KEY_LENGTH);
$publicKey = $RSA->getPublicKey();
$message = $_REQUEST['msg'];
$encryptedPackets = $RSA->encrypt($message);
$cipherText = $RSA->getCipherText($encryptedPackets);
$encryptedPacketsAsString = implode(' ', $encryptedPackets); // just for printing
$plainText = $RSA->decrypt($encryptedPackets);
}
?>
<title>RSA</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Comfortaa&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style/style.css" />
<!---------- CONTAINER CONTAINER ----------------->
<div class="content-container">
<h2>RSA Encryption/Decryption</h2>
<!-----FORM ------->
<div class="row">
<div class="form-container">
<form action="" method="POST">
<div class="row">
<div class="col-20">
<label for="msg">Message</label>
</div>
<div class="col-80">
<textarea id="msg" name="msg" placeholder="Write something.." style="height:200px"></textarea>
</div>
</div>
<div>
<p>
<?php
if (isset($cipherText)) {
echo 'Public Key : ' . $publicKey . '<br/> <br/>';
}
?>
<p>
<?php
if (isset($cipherText)) {
echo 'Cipher Text : ' . $cipherText . '<br/> <br/>';
echo 'Encrypted Packets : <br/>' . $encryptedPacketsAsString;
}
?>
</p>
<p>
<?php
if (isset($plainText))
echo 'Original Text After decrypting: ' . $plainText
?>
</p>
</div>
<div class="row">
<input type="submit" name="submit" value="Encrypt/Decrypt">
</div>
</form>
</div>
</div>
<!------------- END FORM ----------------->
<!------------- END CONTENT-CONTAINER ----------------------->
</div>
<!----------------------------------------------------------->