var arr = new Uint8Array(8);
var crypto = window.crypto || window.webkitCrypto || window.mozCrypto || window.oCrypto || window.msCrypto;
if (crypto) {
crypto.getRandomValues(arr);
} else {
// 如果浏览器不支持window.crypto,则使用Math.random()作为备选方案
for (var i = 0; i < arr.length; i++) {
arr[i] = Math.floor(Math.random() * 256);
}
}
console.log(arr);