Skip to content

Commit 6e28070

Browse files
committed
entropy v4 dist
1 parent 32d2597 commit 6e28070

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

dist/lib/entropy.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var cryptoBytes = function cryptoBytes(count) {
8888
return Buffer.from(Crypto.randomBytes(count));
8989
};
9090

91-
var randomBytes = function randomBytes(count) {
91+
var prngBytes = function prngBytes(count) {
9292
var BYTES_USED_PER_RANDOM_CALL = 6;
9393
var randCount = Math.ceil(count / BYTES_USED_PER_RANDOM_CALL);
9494

@@ -132,7 +132,7 @@ var _class = function () {
132132
throw new Error('Invalid argument for Entropy constructor: Expect params object');
133133
}
134134

135-
if (params.bits === undefined && params.charset === undefined && params.total === undefined && params.risk === undefined) {
135+
if (params.bits === undefined && params.charset === undefined && params.total === undefined && params.risk === undefined && params.prng === undefined) {
136136
throw new Error('Invalid Entropy params');
137137
}
138138

@@ -245,16 +245,8 @@ var _class = function () {
245245
var charset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : propMap.get(this).charset;
246246

247247
var bytesNeeded = charset.bytesNeeded(bitLen);
248-
return this.stringWithBytes(cryptoBytes(bytesNeeded), bitLen, charset);
249-
}
250-
}, {
251-
key: 'stringPRNG',
252-
value: function stringPRNG() {
253-
var bitLen = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : propMap.get(this).bitLen;
254-
var charset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : propMap.get(this).charset;
255-
256-
var bytesNeeded = charset.bytesNeeded(bitLen);
257-
return this.stringWithBytes(randomBytes(bytesNeeded), bitLen, charset);
248+
var bytes = propMap.get(this).prng ? prngBytes(bytesNeeded) : cryptoBytes(bytesNeeded);
249+
return this.stringWithBytes(bytes, bitLen, charset);
258250
}
259251
}, {
260252
key: 'stringWithBytes',

0 commit comments

Comments
 (0)