From: Chris Duncan Date: Sat, 25 Jul 2026 07:15:25 +0000 (-0700) Subject: Brief random bytes instead of weird UUID manipulation. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=058c8d79b240d0d2466098c9e2a5039a0ed04c5f;p=nano-pow.git Brief random bytes instead of weird UUID manipulation. --- diff --git a/index.html b/index.html index 4f307c7..2973394 100644 --- a/index.html +++ b/index.html @@ -42,12 +42,9 @@ SPDX-License-Identifier: GPL-3.0-or-later return gl?.drawingBufferHeight < gl?.drawingBufferWidth ? gl?.drawingBufferHeight : gl?.drawingBufferWidth })(new OffscreenCanvas(0, 0)) - function random(size = 64) { - let hex = '' - while (hex.length < size) { - hex += crypto.randomUUID().replace(/-.*-/g, '') - } - return hex.slice(0, size) + function random (length = 32) { + const bytes = crypto.getRandomValues(new Uint8Array(length)) + return [...bytes].map(b => b.toString(16).padStart(2, '0')).join('') } function average(times, type, effort) {