github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/themes/wind/static/libs/sockjs-client-1.1.0/lib/utils/browser-crypto.js (about) 1 'use strict'; 2 3 if (global.crypto && global.crypto.getRandomValues) { 4 module.exports.randomBytes = function(length) { 5 var bytes = new Uint8Array(length); 6 global.crypto.getRandomValues(bytes); 7 return bytes; 8 }; 9 } else { 10 module.exports.randomBytes = function(length) { 11 var bytes = new Array(length); 12 for (var i = 0; i < length; i++) { 13 bytes[i] = Math.floor(Math.random() * 256); 14 } 15 return bytes; 16 }; 17 }