-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.html
More file actions
89 lines (81 loc) · 3.46 KB
/
decrypt.html
File metadata and controls
89 lines (81 loc) · 3.46 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
{% extends "base.html" %}
{% block content %}
<div class = "flex justify-center p-4">
<div class="container flex justify-center">
<div class="rounded overflow-hidden w-full lg:w-6/12 md:w-6/12 bg-gray-800 mx-3 md:mx-0 lg:mx-0">
<div class="w-full flex justify-between p-3 grid gap-4 justify-center">
<label for = "message" style = "color: white;" class = "text-4xl tracking-tight font-extrabold text-black-900 sm:text-5xl md:text-6xl">Start decryption:</label>
<div class="flex justify-center grid">
<div class="mb-3 w-96 row-auto">
<label for="formFileLg" class="form-label inline-block mb-2 w-96"><b>Key:</b></label>
<input
id = "key"
class="form-control
block
w-full
px-2
py-1
text-sm
font-normal
text-gray-700
bg-white bg-clip-padding
border border-solid border-gray-300
rounded
transition
ease-in-out
m-0
focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none" id="formFileSm"
>
</div>
<div class="mb-3 w-96 row-auto">
<label for="formFileLg" class="form-label inline-block mb-2 w-96"><b>Encrypted Message:</b></label>
<textarea
id = "message"
class="form-control
block
w-full
px-2
py-1.5
text-xl
font-normal
text-gray-700
bg-white bg-clip-padding
border border-solid border-gray-300
rounded
transition
ease-in-out
m-0
focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none" id="formFileLg"
></textarea>
</div>
</div>
<button onclick = "decrypt(document.getElementById('key').value, document.getElementById('message').value)" class = "bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow">
Submit
</button>
</div>
</div>
</div>
</div>
<script>
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
async function decrypt(key, encrypted_message) {
url = "http://localhost:5000/api/decrypt";
fetch(url,{
body : JSON.stringify({key : key, message : encrypted_message}), headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
method : "POST"
}).then(r => r.json()).then(r => {
download("decrypted.txt", r.decrypted_message);
})}
</script>
{% endblock %}