<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
	<head th:replace="layout.html :: head(title='Keys')">
		<title>Keys - OpenRS2 Archive</title>
		<link rel="stylesheet" href="/webjars/bootstrap/css/bootstrap.min.css" />
		<link rel="stylesheet" href="/static/css/openrs2.css" />
		<script src="/webjars/jquery/jquery.min.js" defer></script>
		<script src="/webjars/bootstrap/js/bootstrap.bundle.min.js" defer></script>
	</head>
	<body>
		<nav th:replace="layout.html :: nav(active='keys')"></nav>
		<main class="container">
			<h1>Keys</h1>
			<!--/*@thymesVar id="stats" type="org.openrs2.archive.key.KeyExporter.Stats"*/-->
			<p>
				There are
				<strong th:text="${#numbers.formatInteger(stats.allKeys, 1, 'COMMA')}">0</strong>
				candidate keys in the database, of which
				<strong
					th:text="${#numbers.formatInteger(stats.validKeys, 1, 'COMMA')} + ' (' + ${#numbers.formatPercent(stats.validKeysFraction, 1, 2)} + ')'">0</strong>
				have been validated against at least one encrypted group.
			</p>
			<p>
				There are
				<strong th:text="${#numbers.formatInteger(stats.encryptedGroups, 1, 'COMMA')}">0</strong>
				encrypted groups in the database, of which
				<strong
					th:text="${#numbers.formatInteger(stats.validGroups, 1, 'COMMA')} + ' (' + ${#numbers.formatPercent(stats.validGroupsFraction, 1, 2)} + ')'">0</strong>
				have a validated key. This is equal to the total number of
				validated keys if and only if keys are not re-used. A further
				<strong
					th:text="${#numbers.formatInteger(stats.emptyGroups, 1, 'COMMA')} + ' (' + ${#numbers.formatPercent(stats.emptyGroupsFraction, 1, 2)} + ')'">0</strong>
				groups do not have a validated key, but are empty and can be
				replaced with an unencrypted equivalent with a cache editor.
			</p>

			<h2>Download</h2>
			<p>
				This page allows all raw keys in the database to be exported in
				bulk. It doesn't include the archive/group IDs or versions each
				key is valid for. To export the keys for a particular build of
				the cache, use the download link on the
				<a href="/caches">caches</a> page instead.
			</p>
			<p class="btn-group">
				<a href="/keys/all.json"
				   class="btn btn-primary btn-sm">All candidate keys (JSON)</a>
				<a href="/keys/valid.json"
				   class="btn btn-primary btn-sm">Validated keys (JSON)</a>
			</p>

			<h2>Analysis</h2>
			<p>
				The output of piping all validated keys in binary format into
				<a href="https://www.fourmilab.ch/random/"><code>ent</code></a>
				is:
			</p>
			<!--/*@thymesVar id="analysis" type="java.lang.String"*/-->
			<pre><code th:text="${analysis}"></code></pre>
			<p>
				The keys are sorted in import order, which does not match the
				order they were generated in. This could influence portions of
				<code>ent</code>'s output.
			</p>
		</main>
	</body>
</html>
