mirror of
https://github.com/S2-/securerandomstring.git
synced 2025-08-01 18:00:06 +02:00
if the generated string is not long enough, retry
This commit is contained in:
@@ -32,7 +32,7 @@ function srs(options, cb) {
|
||||
string = string.replace(/\//g, '_').replace(/\+/g, '-');
|
||||
}
|
||||
if (string.length < length) {
|
||||
throw new Error(`Generated string is too short. Please catch this Error and try again.`);
|
||||
return _finish(crypto.randomBytes(length));
|
||||
}
|
||||
return string.substr(0, length);
|
||||
}
|
||||
|
Reference in New Issue
Block a user