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] + " ";
  }
}
posted @ 2020-04-22 20:50  凉月-天  阅读(1001)  评论(0编辑  收藏  举报