如果您不是很受限,您可以使用新的 JavaScript 工具:
function rnd256() {
const bytes = new Uint8Array(32);
// load cryptographically random bytes into array
window.crypto.getRandomValues(bytes);
// convert byte array to hexademical representation
const bytesHex = bytes.reduce((o, v) => o + ('00' + v.toString(16)).slice(-2), '');
// convert hexademical value to a decimal string
return BigInt('0x' + bytesHex).toString(10);
}
console.log( rnd256() );Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4557 次 |
| 最近记录: |