1. 程式人生 > WINDOWS開發 >window.crypto 生成隨機數

window.crypto 生成隨機數

https://developer.mozilla.org/zh-CN/docs/Web/API/Window/crypto

https://www.cnblogs.com/vickylinj/p/11956434.html

genRandomNumbers = function getRandomNumbers() {
  var array = new Uint32Array(10);
  window.crypto.getRandomValues(array);
 
  var randText = document.getElementById("myRandText");
  randText.innerHTML = "The random numbers are: "
  for (var i = 0; i < array.length; i++) {
    randText.innerHTML += array[i] + " ";
  }
}