add better styling and rename pow_client => nojscap

This commit is contained in:
libroot 2025-08-06 18:33:53 +00:00
parent 0a9434be1b
commit 40ee2ea272
3 changed files with 39 additions and 27 deletions

View file

@ -84,9 +84,9 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
hash := sha256.Sum256([]byte(challenge + nonce))
if checkDifficulty(hash[:], difficulty) {
fmt.Fprint(w, "<p>Success! Valid nonce.</p><a href='/'>Try again</a>")
fmt.Fprint(w, "<div style='text-align:center;'><h1>Success! Valid nonce.</h1><a href='/'>Try again</a></div>")
} else {
fmt.Fprint(w, "<p>Invalid nonce.</p><a href='/'>Try again</a>")
fmt.Fprint(w, "<div style='text-align:center;'><p>Invalid nonce.</p><a href='/'>Try again</a></div>")
}
}
@ -104,6 +104,10 @@ var tmpl = template.Must(template.New("page").Parse(`
background: #cacaca;
color: black;
}
::selection {
background: #a60000;
color: white;
}
code {
white-space: break-spaces;
background: black;
@ -143,15 +147,15 @@ var tmpl = template.Must(template.New("page").Parse(`
<p><a href="https://git.libroot.org/libroot/NOJSCAP/" target="_blank">https://git.libroot.org/libroot/NOJSCAP/</a></p>
<p>If you don't already have the <b><em>NOJSCAP</em></b> client:</p>
<code>$ git clone https://git.libroot.org/libroot/NOJSCAP/$ cd NOJSCAP/client/</code>
<p><code>$ python3 pow_client.py {{.Challenge}} {{.Difficulty}}</code></p>
<p><code>$ python3 nojscap.py {{.Challenge}} {{.Difficulty}}</code></p>
<p><strong>Go:</strong></p>
<p><code>$ go run pow_client.go {{.Challenge}} {{.Difficulty}}</code></p>
<p><code>$ go run nojscap.go {{.Challenge}} {{.Difficulty}}</code></p>
<p><strong>Node.js:</strong></p>
<p><code>$ node pow_client.js {{.Challenge}} {{.Difficulty}}</code></p>
<p><code>$ node nojscap.js {{.Challenge}} {{.Difficulty}}</code></p>
<p><strong>Rust:</strong></p>
<p><code>$ rustc pow_client.rs -o pow_client_rs$ pow_client_rs {{.Challenge}} {{.Difficulty}}</code></p>
<p><code>$ rustc nojscap.rs -o nojscap_rs$ nojscap_rs {{.Challenge}} {{.Difficulty}}</code></p>
<p><strong>C:</strong></p>
<p><code>$ gcc -O2 -o pow_client pow_client.c -lssl -lcrypto$ ./pow_client {{.Challenge}} {{.Difficulty}}</code></p>
<p><code>$ gcc -O2 -o nojscap nojscap.c -lssl -lcrypto$ ./nojscap {{.Challenge}} {{.Difficulty}}</code></p>
<form method="POST">
<input type="hidden" name="challenge" value="{{.Challenge}}">
<label class="h">Nonce: <input name="nonce"></label>