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

3 Commits

Author SHA1 Message Date
Mark Stosberg
a6dc243138 Clarify that the default char set returned is base64 encoded
Also, link to a neutral URL for the MIT license instead of the node-ses repo.
2019-07-12 09:20:40 -04:00
s2
cb6bbee3b1 add one more test 2017-11-26 22:04:14 +01:00
s2
0259480474 just a newline 2017-11-26 21:57:41 +01:00
2 changed files with 13 additions and 3 deletions

View File

@@ -8,7 +8,9 @@ Node.js module that generates a cryptographically secure random string with a gi
var srs = require('secure-random-string');
```
### Default behavior: Generate a random string 32 characters long.
### Default behavior: Generate a random Base64 encoded string 32 characters long.
This may include alphanumeric characters as well as the following characters: +, /, =.
```javascript
// Sync
@@ -59,9 +61,9 @@ the async API returns the error to the callback.
## Contributors
[Mark Stosberg](https://github.com/markstos)
[Mark Stosberg](https://github.com/markstos)
[Sandro Gomez](https://github.com/mrsangrin)
## License
[MIT](https://github.com/aheckmann/node-ses/blob/master/LICENSE)
[MIT](https://opensource.org/licenses/MIT)

View File

@@ -56,6 +56,14 @@ srs({alphanumeric: true}, function(err, sr) {;
true
);
});
srs({alphanumeric: true, length: 40}, function(err, sr) {;
test('Must contain alphanumeric only and be 40 chars long',
sr.match(/^[a-zA-Z0-9_]*$/g)[0] === sr && sr.length === 40,
true
);
});
// sync tests
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);