Skip to content

Commit

Permalink
Fix browser support
Browse files Browse the repository at this point in the history
Use randomBytes instead of crypto.randomBytes
  • Loading branch information
mindsers authored Dec 21, 2021
1 parent 6255c90 commit f9847f8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/randomstring.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";

var crypto = require('crypto');
var randomBytes = require('randombytes');
var Charset = require('./charset.js');

Expand All @@ -26,7 +25,7 @@ function processString(buf, initialString, chars, reqLen, maxByte) {
}

function getAsyncString(string, chars, length, maxByte, cb) {
crypto.randomBytes(length, function(err, buf) {
randomBytes(length, function(err, buf) {
if (err) {
// Since it is waiting for entropy, errors are legit and we shouldn't just keep retrying
cb(err);
Expand Down

0 comments on commit f9847f8

Please sign in to comment.