mirror of
https://github.com/privacyguides/privacyguides.org.git
synced 2024-12-20 05:14:35 -05:00
added guard clause
This commit is contained in:
parent
78634330de
commit
91fb2972b4
@ -1,5 +1,8 @@
|
|||||||
var passwordGenerator = (function() {
|
var passwordGenerator = (function() {
|
||||||
var generateRandomNum = function (max) {
|
var generateRandomNum = function (max) {
|
||||||
|
if (!window.crypto || !window.crypto.getRandomValues) {
|
||||||
|
throw new Error('Unsupported browser.');
|
||||||
|
}
|
||||||
var array = new Uint8Array(1);
|
var array = new Uint8Array(1);
|
||||||
window.crypto.getRandomValues(array);
|
window.crypto.getRandomValues(array);
|
||||||
var range = max + 1;
|
var range = max + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user