]> git.codecow.com Git - nano-pow.git/commitdiff
Brief random bytes instead of weird UUID manipulation.
authorChris Duncan <chris@codecow.com>
Sat, 25 Jul 2026 07:15:25 +0000 (00:15 -0700)
committerChris Duncan <chris@codecow.com>
Sat, 25 Jul 2026 07:15:25 +0000 (00:15 -0700)
index.html

index 4f307c747259ce855d92c961250aa32d779950eb..297339432daf1073cc2b435a32bc2a41fff79389 100644 (file)
@@ -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) {