-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
96 lines (86 loc) · 3.85 KB
/
index.php
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
90
91
92
93
94
95
96
<?php
use ProvablyFair\Algorithm;
use ProvablyFair\ProvablyFair;
use ProvablyFair\Seed;
require __DIR__ . '/vendor/autoload.php';
const ALGORITHM = 'sha512';
const SERVER = 'example';
const CLIENT = 'example';
const AMOUNT = 100;
const PREPEND = false;
$results = (new ProvablyFair(
$clientSeed = new Seed($_GET['client'] ?? CLIENT),
$serverSeed = new Seed($_GET['server'] ?? SERVER),
$algorithm = new Algorithm($_GET['algorithm'] ?? ALGORITHM),
))->generate(
$amount = intval($_GET['amount'] ?? AMOUNT),
$prepend = boolval($_GET['prepend'] ?? PREPEND)
)
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Provably Fair Demo</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1 class="mt-5">Provably Fair Demo</h1>
<hr>
<form class="mb-5">
<div class="row">
<div class="col-12 col-md-3">
<label class="form-label" for="algorithm">Algorithm</label>
<select class="form-select" name="algorithm" id="algorithm">
<?php foreach (hash_hmac_algos() as $available_algorithm): ?>
<option <?php echo $available_algorithm === $algorithm->value ? 'selected' : '' ?> value="<?php echo $available_algorithm ?>"><?php echo $available_algorithm ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-12 col-md-3">
<label class="form-label" for="server">Server seed</label>
<input class="form-control" id="server" autocomplete="off" type="text" name="server" value="<?php echo $serverSeed->value ?>" required>
</div>
<div class="col-12 col-md-3">
<label class="form-label" for="client">Client seed</label>
<input class="form-control" id="client" autocomplete="off" type="text" name="client" value="<?php echo $clientSeed->value ?>" required>
</div>
<div class="col-12 col-md-3">
<label class="form-label" for="amount">Amount of results</label>
<input class="form-control" id="amount" autocomplete="off" type="number" min="0" name="amount" value="<?php echo $amount ?>" required>
</div>
</div>
<div class="mt-3">
<input type="submit" class="btn btn-primary me-2" value="Submit">
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="prepend" name="prepend" <?php echo $prepend === true ? 'checked' : '' ?> >
<label class="form-check-label" for="prepend">Prepend original server seed result</label>
</div>
</div>
</form>
<table class="table table-responsive w-100 d-block d-md-table">
<tr>
<th>#</th>
<th>Hash</th>
<th>Result</th>
</tr>
<?php foreach ($results as $result): ?>
<tr>
<td>
<small><?php echo $result->index ?></small>
</td>
<td>
<pre class="m-0"><?php echo $result->hash ?></pre>
</td>
<td>
<strong><?php echo $result->value ?></strong>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</body>
</html>