mirror of
https://github.com/S2-/securerandomstring.git
synced 2025-08-02 18:30:04 +02:00
rename module
This commit is contained in:
10
README.md
10
README.md
@@ -1,17 +1,17 @@
|
|||||||
# securerandomstring
|
# secure-random-string
|
||||||
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
|
||||||
`require` it
|
`require` it
|
||||||
|
|
||||||
```
|
```
|
||||||
var securerandomstring = require('securerandomstring');
|
var srs = require('secure-random-string');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
generate a random string that is 32 chars long (the default)
|
generate a random string that is 32 chars long (the default)
|
||||||
```
|
```
|
||||||
securerandomstring(function(sr) {
|
srs(function(sr) {
|
||||||
console.log(sr);
|
console.log(sr);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@@ -19,7 +19,7 @@ securerandomstring(function(sr) {
|
|||||||
|
|
||||||
generate a random string that is 256 chars long
|
generate a random string that is 256 chars long
|
||||||
```
|
```
|
||||||
securerandomstring({length: 256}, function(sr) {
|
srs({length: 256}, function(sr) {
|
||||||
console.log(sr);
|
console.log(sr);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
@@ -27,7 +27,7 @@ securerandomstring({length: 256}, function(sr) {
|
|||||||
|
|
||||||
generate a random string that is 20 chars long and is url safe (can be used as a url token)
|
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) {
|
srs({length: 20, urlsafe: true}, function(sr) {
|
||||||
console.log(sr);
|
console.log(sr);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
|
|
||||||
function securerandomstring(options, cb) {
|
function srs(options, cb) {
|
||||||
if (typeof(options) === 'function') {
|
if (typeof(options) === 'function') {
|
||||||
cb = options;
|
cb = options;
|
||||||
options = {};
|
options = {};
|
||||||
@@ -23,4 +23,4 @@ function securerandomstring(options, cb) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = securerandomstring;
|
module.exports = srs;
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "securerandomstring",
|
"name": "secure-random-string",
|
||||||
"version": "0.0.3",
|
"version": "0.0.1",
|
||||||
"description": "Generates a secure random string with a given length",
|
"description": "Generates a secure random string with a given length",
|
||||||
"main": "lib/securerandomstring.js",
|
"main": "lib/securerandomstring.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
10
tests.js
10
tests.js
@@ -1,4 +1,4 @@
|
|||||||
var securerandomstring = require('./lib/securerandomstring.js');
|
var srs = require('./lib/secure-random-string.js');
|
||||||
|
|
||||||
|
|
||||||
//my awesome test framework
|
//my awesome test framework
|
||||||
@@ -29,28 +29,28 @@ var test = function(name, what, ref, c) {
|
|||||||
|
|
||||||
|
|
||||||
//the actual tests
|
//the actual tests
|
||||||
securerandomstring(function(sr) {
|
srs(function(sr) {
|
||||||
test('generate a random string 32 chars long',
|
test('generate a random string 32 chars long',
|
||||||
sr.length,
|
sr.length,
|
||||||
32
|
32
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
securerandomstring({length: 1}, function(sr) {
|
srs({length: 1}, function(sr) {
|
||||||
test('generate a random string 1 char long',
|
test('generate a random string 1 char long',
|
||||||
sr.length,
|
sr.length,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
securerandomstring({length: 256}, function(sr) {
|
srs({length: 256}, function(sr) {
|
||||||
test('generate a random string 256 chars long',
|
test('generate a random string 256 chars long',
|
||||||
sr.length,
|
sr.length,
|
||||||
256
|
256
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
securerandomstring({length: 256, urlsafe: true}, function(sr) {
|
srs({length: 256, urlsafe: true}, function(sr) {
|
||||||
test('generate a urlsafe random string 256 chars long',
|
test('generate a urlsafe random string 256 chars long',
|
||||||
sr.length,
|
sr.length,
|
||||||
256
|
256
|
||||||
|
Reference in New Issue
Block a user