Blame view
node_modules/shortid/lib/random/random-byte-browser.js
383 Bytes
f7563de62
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
'use strict'; var crypto = typeof window === 'object' && (window.crypto || window.msCrypto); // IE 11 uses window.msCrypto function randomByte() { if (!crypto || !crypto.getRandomValues) { return Math.floor(Math.random() * 256) & 0x30; } var dest = new Uint8Array(1); crypto.getRandomValues(dest); return dest[0] & 0x30; } module.exports = randomByte; |