Repository navigation
Expand file tree
/
Copy pathencrypt.html
More file actions
73 lines (64 loc) · 2.36 KB
/
Copy pathencrypt.html
File metadata and controls
73 lines (64 loc) · 2.36 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
{% 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">Message to encrypt:</label>
<textarea
class="
form-control
block
w-full
px-3
py-1.5
text-base
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="message"
rows="3"
placeholder="Your message"
name = "message"
></textarea>
<button onclick = "encrypt(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 encrypt(message) {
url = "http://localhost:5000/api/encrypt"
fetch(url,{
body : JSON.stringify({message : message}), headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
method : "POST"
}).then(r => r.json()).then(r => {
key = r.key;
encrypted_message = r.encrypted_message;
download("key.txt", key);
download("encrypted.txt", encrypted_message);
})
}
</script>
{% endblock %}