mirror of
https://github.com/S2-/securerandomstring.git
synced 2025-08-02 10:20:05 +02:00
add urlsafe parameter
This commit is contained in:
32
README.md
32
README.md
@@ -1,5 +1,33 @@
|
|||||||
# securerandomstring
|
# securerandomstring
|
||||||
a node module that generates a secure random string with a given length
|
a node module that generates a secure random string with a given length
|
||||||
|
|
||||||
## usage
|
## Usage
|
||||||
see `tests.js`
|
`require` it
|
||||||
|
|
||||||
|
```
|
||||||
|
var securerandomstring = require('securerandomstring');
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
generate a random string that is 32 chars long (the default)
|
||||||
|
```
|
||||||
|
securerandomstring(function(sr) {
|
||||||
|
console.log(sr);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
generate a random string that is 256 chars long
|
||||||
|
```
|
||||||
|
securerandomstring({length: 256}, function(sr) {
|
||||||
|
console.log(sr);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
generate a random string that is 20 chars long and is url safe (can be used as a url token)
|
||||||
|
```
|
||||||
|
securerandomstring({length: 20, urlsafe: true}, function(sr) {
|
||||||
|
console.log(sr);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
Reference in New Issue
Block a user