()
| 60 | * As Math.random() is cryptographically not safe to use |
| 61 | */ |
| 62 | var cryptoSecureRandomInt = function () { |
| 63 | if (crypto) { |
| 64 | // Use getRandomValues method (Browser) |
| 65 | if (typeof crypto.getRandomValues === 'function') { |
| 66 | try { |
| 67 | return crypto.getRandomValues(new Uint32Array(1))[0]; |
| 68 | } catch (err) {} |
| 69 | } |
| 70 | |
| 71 | // Use randomBytes method (NodeJS) |
| 72 | if (typeof crypto.randomBytes === 'function') { |
| 73 | try { |
| 74 | return crypto.randomBytes(4).readInt32LE(); |
| 75 | } catch (err) {} |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | throw new Error('Native crypto module could not be used to get secure random number.'); |
| 80 | }; |
| 81 | |
| 82 | /* |
| 83 | * Local polyfill of Object.create |
no outgoing calls
no test coverage detected
searching dependent graphs…