diff --git a/server/go-http/server.go b/server/go-http/server.go index ea39af5..3dbe9f8 100644 --- a/server/go-http/server.go +++ b/server/go-http/server.go @@ -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, "

Success! Valid nonce.

Try again") + fmt.Fprint(w, "

Success! Valid nonce.

Try again
") } else { - fmt.Fprint(w, "

Invalid nonce.

Try again") + fmt.Fprint(w, "

Invalid nonce.

Try again
") } } @@ -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(`

https://git.libroot.org/libroot/NOJSCAP/

If you don't already have the NOJSCAP client:

$ git clone https://git.libroot.org/libroot/NOJSCAP/$ cd NOJSCAP/client/ -

$ python3 pow_client.py {{.Challenge}} {{.Difficulty}}

+

$ python3 nojscap.py {{.Challenge}} {{.Difficulty}}

Go:

-

$ go run pow_client.go {{.Challenge}} {{.Difficulty}}

+

$ go run nojscap.go {{.Challenge}} {{.Difficulty}}

Node.js:

-

$ node pow_client.js {{.Challenge}} {{.Difficulty}}

+

$ node nojscap.js {{.Challenge}} {{.Difficulty}}

Rust:

-

$ rustc pow_client.rs -o pow_client_rs$ pow_client_rs {{.Challenge}} {{.Difficulty}}

+

$ rustc nojscap.rs -o nojscap_rs$ nojscap_rs {{.Challenge}} {{.Difficulty}}

C:

-

$ gcc -O2 -o pow_client pow_client.c -lssl -lcrypto$ ./pow_client {{.Challenge}} {{.Difficulty}}

+

$ gcc -O2 -o nojscap nojscap.c -lssl -lcrypto$ ./nojscap {{.Challenge}} {{.Difficulty}}

diff --git a/server/python-flask/server.py b/server/python-flask/server.py index 3b5c4b9..3734917 100644 --- a/server/python-flask/server.py +++ b/server/python-flask/server.py @@ -39,6 +39,10 @@ def index(): background: #cacaca; color: black; }} + ::selection {{ + background: #a60000; + color: white; + }} code {{ white-space: break-spaces; background: black; @@ -81,26 +85,26 @@ def index(): $ cd NOJSCAP/client/


- $ python3 pow_client.py {challenge} {DIFFICULTY} + $ python3 nojscap.py {challenge} {DIFFICULTY}

Go:

- $ go run pow_client.go {challenge} {DIFFICULTY} + $ go run nojscap.go {challenge} {DIFFICULTY}

Node.js:

- $ node pow_client.js {challenge} {DIFFICULTY} + $ node nojscap.js {challenge} {DIFFICULTY}

Rust:

-$ rustc pow_client.rs -o pow_client_rs -$ pow_client_rs {challenge} {DIFFICULTY} +$ rustc nojscap.rs -o nojscap_rs +$ nojscap_rs {challenge} {DIFFICULTY} Requires Rust and sha2 crate if using the Cargo version.

@@ -108,8 +112,8 @@ $ pow_client_rs {challenge} {DIFFICULTY} C:

-$ gcc -O2 -o pow_client pow_client.c -lssl -lcrypto -$ ./pow_client {challenge} {DIFFICULTY} +$ gcc -O2 -o nojscap nojscap.c -lssl -lcrypto +$ ./nojscap {challenge} {DIFFICULTY} Required: GCC or any C compiler. OpenSSL development libraries (libssl-dev on Debian-based systems)

@@ -130,7 +134,7 @@ def submit(): challenge_store.pop(challenge) combined = (challenge + nonce).encode() h = hashlib.sha256(combined).digest() - return "

Success! Valid nonce.

Try again" if check_difficulty(h, DIFFICULTY) else "

Invalid nonce.

Try again" + return "

Success! Valid nonce.

Try again
" if check_difficulty(h, DIFFICULTY) else "

Invalid nonce.

Try again
" app.run(port=3000) diff --git a/server/ts-express/server.ts b/server/ts-express/server.ts index edff301..e11c469 100644 --- a/server/ts-express/server.ts +++ b/server/ts-express/server.ts @@ -32,7 +32,7 @@ function checkDifficulty(hash: Buffer, bits: number): boolean { return true; } -app.get('/', (_req: Request, res: Response) => { +app.get('/NOJSCAP-demo', (_req: Request, res: Response) => { const challenge = generateChallenge(); challengeStore.set(challenge, Date.now()); res.send(` @@ -49,6 +49,10 @@ app.get('/', (_req: Request, res: Response) => { background: #cacaca; color: black; } + ::selection { + background: #a60000; + color: white; + } code { white-space: break-spaces; background: black; @@ -94,36 +98,36 @@ $ cd NOJSCAP/client/
Python:

- +

Go:

- +

Node.js:

- +

Rust:

-

Show compilation commands$ rustc pow_client.rs -o pow_client_rs +
Show compilation commands$ rustc nojscap.rs -o nojscap_rs Requires Rust and sha2 crate if using the Cargo version.
- +

C:

-

Show compilation commands$ gcc -O2 -o pow_client pow_client.c -lssl -lcrypto +
Show compilation commands$ gcc -O2 -o nojscap nojscap.c -lssl -lcrypto Required: GCC or any C compiler. OpenSSL development libraries (libssl-dev on Debian-based systems)
- +

@@ -136,7 +140,7 @@ $ cd NOJSCAP/client/
`); }); -app.post('/', (req: Request, res: Response) => { +app.post('/NOJSCAP-demo', (req: Request, res: Response) => { const { challenge, nonce } = req.body as { challenge?: string; nonce?: string }; if (!challenge || !nonce || !challengeStore.has(challenge)) { return res.send('Invalid input.'); @@ -145,10 +149,10 @@ app.post('/', (req: Request, res: Response) => { challengeStore.delete(challenge); const hash = hashSha256(challenge + nonce); if (checkDifficulty(hash, DIFFICULTY)) { - res.send('

Success! Valid nonce.

Try again'); + res.send('

Success! Valid nonce.

Try again
'); } else { - res.send('

Invalid nonce.

Try again'); + res.send('

Invalid nonce.

Try again
'); } }); -app.listen(3000, () => console.log('Server running at http://localhost:3000')); +app.listen(3000, () => console.log('/NOJSCAP-demo server running at http://localhost:3000'));