mirror of
https://github.com/S2-/securerandomstring.git
synced 2025-08-05 11:30:07 +02:00
Compare commits
3 Commits
v1.1.0
...
a6dc243138
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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
|
||||
@@ -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)
|
||||
|
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