JavaScript でランダムな値を得るよ
code:random32.js
const crypto = window.crypto
// 32 bytesのランダムな値を得ます
const r = crypto.getRandomValues(new Uint8Array(32))
console.log(r)
// => Uint8Array(32) 68, 32, 50, 185, 133, 141, 117, 9, 241, 142, 233, 252, 57, 252, 163, 21, 60, 215, 51, 71, 106, 179, 72, 118, 122, 165, 229, 125, 203, 157, 122, 8 // 16進数文字列形式に変換します。
const hex = Array.from(r).map(v => v.toString(16).padStart(2, "0")).join('')
console.log(hex)
// => 442032b9858d7509f18ee9fc39fca3153cd733476ab348767aa5e57dcb9d7a08
alert(hex)
code:random.js
const BYTE_SIZE = 4
const crypto = window.crypto
const r = crypto.getRandomValues(new Uint8Array(BYTE_SIZE))
const hex = Array.from(r).map(v => v.toString(16).padStart(2, "0")).join('')
alert(hex)