-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsecret-encode.html
82 lines (63 loc) · 2.18 KB
/
secret-encode.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="cache-control" content="max-age=0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="cache-control" content="no-store">
<meta http-equiv="pragma" content="no-cache" />
<title>Encode Secret</title>
<script type="text/javascript" src="lib/secrets.min.js"></script>
<script type="text/javascript" src="lib/jquery.min.js"></script>
<style type="text/css">
.shares_input {
text-align:center;
}
.firstC {
width:75px;
}
th, td {
border: 1px solid black;
}
th {
text-align:center;
}
</style>
</head>
<body>
<h2>Le Secret :</h2>
<h3>Content :</h3>
<input type="text" autocomplete="off" class="encode_secret_param" id="encode_secret_secret" style="width:80%">
<br><br>
<h3>Number of shares :</h3>
<input id="number_shares" type="number" value="4" min="2">
<br><br>
<h3>Minimal number of part :</h3>
<input id="minimum_part" type="number" value="3" min="2">
<br><br>
<input type="button" value="Submit" id="valid_button">
<h2>Parts :</h2>
<div id="secret_parts" style="font-weight:bold;color:blue;background-color:yellow;width:85%;word-break:break-all;margin:auto;">??????</div>
<script type="text/javascript">
$("#valid_button").on("click",(function(){
var secret = secrets.str2hex($("#encode_secret_secret").val());
if (secret.length >= 4) {
var number_shares = parseInt($("#number_shares").val());
var minimum_shares = parseInt($("#minimum_part").val());
var shares = secrets.share(secret, number_shares, minimum_shares);
var table = "<table><th class=\"firstC\">N° Part</th><th>Parts</th>";
for ( var i = 0; i < shares.length; i++ ) {
var part = shares[i];
var line = "<tr>";
line += "<td>"+(i+1)+"</td>";
line += "<td>"+part+"</td>";
line += "</tr>";
table += line;
}
table += "</table>";
$("#secret_parts").html(table);
}
}));
</script>
</body>
</html>