Browse Source

Throw error on invalid bit value

pull/2/head
Luke Childs 6 years ago
parent
commit
a55496b3ec
  1. 4
      src/index.js

4
src/index.js

@ -20,6 +20,10 @@ const binaryToBytes = binaryString => Buffer.from(
const randomNumberBetween = (min, max) => Math.floor(parseInt(randomBytes(1).toString('hex'), 16) / 256 * (max - min + 1) + min);
const dogeSeed = (bits = 128) => {
if (bits <= 0 || bits % 8 !== 0) {
throw TypeError('bits must be divisible by 8');
}
const entropy = randomBytes(bits / 8);
const words = bytesToBinary(entropy).match(/.{1,11}/g);

Loading…
Cancel
Save