Socket
Socket
Sign inDemoInstall

generate-password

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.1 to 1.4.2

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# 1.4.2 / 2019-6-16
Includes a performance improvement in the random number generator.
#### Notable Changes
- [`ea642553c`](https://github.com/brendanashworth/generate-password/commit/ea642553c5ba327989f36d0b0f2d4e80ff25b45a) - Optimized fetch of random values using cache (Sebastien ROBERT)
# 1.4.1 / 2018-10-28

@@ -2,0 +8,0 @@ Bug fix to `randomNumber()` function that reduced entropy, resulting in a bias towards letters, generally.

2

package.json
{
"name": "generate-password",
"version": "1.4.1",
"version": "1.4.2",
"description": "Easy library for generating unique passwords.",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -5,8 +5,25 @@ var crypto = require('crypto');

const RANDOM_BATCH_SIZE = 256;
var randomIndex;
var randomBytes;
var getNextRandomValue = function() {
if (randomIndex === undefined || randomIndex >= randomBytes.length) {
randomIndex = 0;
randomBytes = crypto.randomBytes(RANDOM_BATCH_SIZE);
}
var result = randomBytes[randomIndex];
randomIndex += 1;
return result;
};
// Generates a random number
var randomNumber = function(max) {
// gives a number between 0 (inclusive) and max (exclusive)
var rand = crypto.randomBytes(1)[0];
var rand = getNextRandomValue();
while (rand >= 256 - (256 % max)) {
rand = crypto.randomBytes(1)[0];
rand = getNextRandomValue();
}

@@ -13,0 +30,0 @@ return rand % max;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc