1
0
mirror of https://github.com/S2-/securerandomstring.git synced 2025-08-02 18:30:04 +02:00

Compare commits

..

5 Commits

Author SHA1 Message Date
s2
388dd79a47 changelog 2024-09-26 13:37:30 +02:00
s2
bed8113750 1.1.4 2024-09-26 13:27:50 +02:00
s2
a23c85cabe update package.json 2024-09-26 13:22:31 +02:00
s2
af5b2eaced if the generated string is not long enough, retry 2024-09-26 13:18:22 +02:00
s2
51274ca17b add 10 chars test 2024-09-26 13:17:57 +02:00
4 changed files with 12 additions and 5 deletions

View File

@@ -4,6 +4,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [1.1.4] 2024-09-26
## Changes
- In previous versions, if there was not enough entropy on the system, `securerandomstring` would throw an exception. Now it will retry to generate a random string until it succeeds, or the call stack becomes full.
## [1.1.0] 2017-12-26
### New Features

View File

@@ -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);
}

View File

@@ -1,6 +1,6 @@
{
"name": "secure-random-string",
"version": "1.1.3",
"version": "1.1.4",
"description": "Generates a secure random string with a given length",
"main": "lib/secure-random-string.js",
"scripts": {
@@ -8,7 +8,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/S2-/securerandomstring.git"
"url": "https://github.com/5im-0n/securerandomstring.git"
},
"keywords": [
"crypto",
@@ -24,7 +24,7 @@
],
"license": "MIT",
"bugs": {
"url": "https://github.com/S2-/securerandomstring/issues"
"url": "https://github.com/5im-0n/securerandomstring/issues"
},
"homepage": "https://github.com/S2-/securerandomstring"
"homepage": "https://github.com/5im-0n/securerandomstring"
}

View File

@@ -68,6 +68,7 @@ srs({alphanumeric: true, length: 40}, function(err, sr) {;
test('generate a random string 32 chars long (sync)', srs().length, 32);
test('generate a random string 1 chars long (sync)', srs({length: 1}).length, 1);
test('generate a random string 256 chars long (sync)', srs({length: 256}).length, 256);
test('generate a random string 10 chars long (sync)', srs({length: 10}).length, 10);
//in 2000 chars there should be at least one substitution