mirror of
https://github.com/S2-/securerandomstring.git
synced 2025-08-02 18:30:04 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
94f2eadf63 | |||
394d13d5a7 | |||
![]() |
a6dc243138 | ||
cb6bbee3b1 | |||
0259480474 |
@@ -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
|
||||
@@ -64,4 +66,4 @@ the async API returns the error to the callback.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/aheckmann/node-ses/blob/master/LICENSE)
|
||||
[MIT](https://opensource.org/licenses/MIT)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "secure-random-string",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.2",
|
||||
"description": "Generates a secure random string with a given length",
|
||||
"main": "lib/secure-random-string.js",
|
||||
"scripts": {
|
||||
@@ -19,7 +19,9 @@
|
||||
"token"
|
||||
],
|
||||
"author": "Simon Santoro",
|
||||
"contributors": ["Mark Stosberg <mark@rideamigos.com>"],
|
||||
"contributors": [
|
||||
"Mark Stosberg <mark@rideamigos.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/S2-/securerandomstring/issues"
|
||||
|
8
tests.js
8
tests.js
@@ -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);
|
||||
|
Reference in New Issue
Block a user