Skip to content

Commit cfc9dce

Browse files
committed
update README
1 parent 339c095 commit cfc9dce

File tree

1 file changed

+50
-98
lines changed

1 file changed

+50
-98
lines changed

README.md

Lines changed: 50 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
Generate random strings, strings with mask and strength passwords
33
============================
44
`generate-string` is a string generator that build random strings, strings with mask and passwords with password-strength tester.
5-
It is lightweight, extensible, has no dependencies, and can be used on the server with NodeJS or in-browser with JavaScript.
5+
It is lightweight, extensible, has no dependencies, and can be used on the server with NodeJS or in-browser with JS.
66

77
[![Build Status](https://travis-ci.com/LucasNaja/generate-strings.svg?branch=master)](https://travis-ci.com/LucasNaja/generate-strings)
88

9+
[![Generate-Strings NPM](https://nodei.co/npm/generate-strings.png?downloads=true&downloadRank=true)](http://npmjs.org/package/generate-strings)
10+
11+
912
Installing
1013
----------
1114
### Server-side (NodeJS)
@@ -42,129 +45,78 @@ Features
4245
Usage
4346
-----
4447
After you've included it into your project, using the module is straightforward:
48+
#### `generate({options})`
4549
4650
### Server-side
4751
```javascript
4852
// require the module
4953
const str = require('generate-strings')
5054
51-
// invoke generate() to generate a random string
52-
let string = str.generate(/* settings into object */)
53-
54-
// shows the result
55-
console.log(string) // something like ,9nlg4^]
55+
console.log(str.generate())
5656
```
5757
5858
### In-browser
5959
```javascript
6060
// in the browser, including the script will make a generate() function available.
61-
let str = generate() // will return a string
61+
console.log(generate())
6262
```
6363
6464
Configuring
6565
-----------
6666
The module may be configured as follows:
67+
OBS: The settings shown below are the defaults.
6768
6869
```javascript
6970
const str = require('generate-strings')
7071
71-
// Pass a hash of settings into an object. The settings shown here are the defaults.
72+
// Pass a hash of settings into an object.
7273
let settings = {
73-
/*
74-
*************************************************
75-
Settings for all modes
76-
*************************************************
77-
*/
78-
amount: 1,
79-
// Number, set the amount of strings to generate
80-
81-
mode: 'random',
82-
// String, set the mode. Allows "random", "mask" and "password"
83-
84-
upperCases: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
85-
// String, upperCases characters that will be generated
86-
87-
lowerCases: 'abcdefghijklmnopqrstuvwxyz',
88-
// String, lowerCase characters that will be generated
89-
90-
specials: '!@#$%&*()=[]{}',
91-
// String, special characters that will be generated
92-
93-
numbers: '0123456789',
94-
// String, numbers that will be generated
95-
96-
/*
97-
*************************************************
98-
Settings for random string and password modes
99-
**************************************************
100-
*/
101-
length: 8,
102-
// Number, length of the strings
103-
// when mode is password, must be > 1
104-
105-
upperCase: true,
106-
// Boolean, set a boolean value to generate strings with upperCase characters
107-
108-
lowerCase: true,
109-
// Boolean, set a boolean value to generate strings with lowerCase characters
110-
111-
special: false,
112-
// Boolean, set a boolean value to generate strings with special characters
113-
114-
number: true,
115-
// Boolean, set a boolean value to generate strings with numbers
116-
117-
/*
118-
*************************************************
119-
Settings for password mode
120-
*************************************************
121-
*/
122-
showStrength: false,
123-
// Boolean, shows the password strength
124-
// like: strength: high. Possible results: unacceptable, terrible, medium, good and high.
125-
126-
firstCharType: 'random',
127-
// String, set the type of first character when generate a password
128-
// 'random' - random type
129-
// 'upperCase' - to upperCase character
130-
// 'lowerCase' - to lowerCase character
131-
// 'special' - to special character
132-
// 'number' - to number
133-
134-
excludeEqualChars: true,
135-
// Boolean, exclude characters that are equals
136-
// E.g: aa, AA, @@, 00
137-
138-
/*
139-
*************************************************
140-
Settings for mask mode
141-
*************************************************
142-
*/
143-
mask: '@#$%-@#$%-@#$%-@#$%',
144-
// String, mask to generate the strings
145-
// @ - to upperCase characters
146-
// # - to lowerCase characters
147-
// $ - to special characters
148-
// % - to numbers
149-
// others: no will be changed
150-
151-
upperCaseMask: '@',
152-
// String, must be 1 character
153-
154-
lowerCaseMask: '#',
155-
// String, must be 1 character
156-
157-
specialMask: '$',
158-
// String, must be 1 character
159-
160-
numberMask: '%'
161-
// String, must be 1 character
74+
// available settings will be shown below
16275
}
16376
16477
// and then:
16578
let string = str.generate(settings)
16679
```
16780
81+
### Available options for all threee modes (**random, password, mask**)
82+
83+
| Name | Type | Description | Default Value | Allowed values |
84+
|------------|---------|--------------------------------------------|------------------------------|------------------------------|
85+
| amount | Integer | Amount of strings to generate | 1 | 0-Number.MAX_SAFE_INTEGER |
86+
| mode | String | Different modes to generate a string | 'random' | 'random', 'mask', 'password' |
87+
| upperCases | String | UpperCase letters to be generate | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | 'A-Z' |
88+
| lowerCases | String | LowerCase letters to be generate | 'abcdefghijklmnopqrstuvwxyz' | 'a-z' |
89+
| specials | String | Special letters to be generate | '!@#$%&*()=[]{}' | All special characters |
90+
| numbers | String | Numbers to be generate | '0123456789' | 0-9 |
91+
92+
### Available options for both **random and password** modes
93+
94+
| Name | Type | Description | Default Value | Allowed values |
95+
|-----------|---------|--------------------------------------------|---------------|---------------------------|
96+
| length | Integer | Size of the strings that will be generated | 8 | 0-Number.MAX_SAFE_INTEGER |
97+
| upperCase | Boolean | Determines whether it will be generated | true | true and false |
98+
| lowerCase | Boolean | Determines whether it will be generated | true | true and false |
99+
| special | Boolean | Determines whether it will be generated | false | true and false |
100+
| number | Boolean | Determines whether it will be generated | true | true and false |
101+
102+
### Available options for **password** mode
103+
104+
| Name | Type | Description | Default Value | Allowed values |
105+
|-------------------|---------|----------------------------------------|---------------|---------------------------------------------------------|
106+
| showStrength | Boolean | Shows the password strength | false | true and false |
107+
| firstCharType | String | Determines the type of first character | 'random' | 'random', 'upperCase', 'lowerCase', 'special', 'number' |
108+
| excludeEqualChars | Boolean | Excludes characters that are equals | true | true and false |
109+
110+
### Available options for **mask** mode
111+
112+
| Name | Type | Description | Default Value | Allowed values |
113+
|---------------|--------|-----------------------------------------------|-----------------------|----------------|
114+
| mask | String | Mask to string that will be generated | '@#$%-@#$%-@#$%-@#$%' | * |
115+
| upperCaseMask | String | Letter that will be replaced a upperCase char | '@' | '*' |
116+
| lowerCaseMask | String | Letter that will be replaced a upperCase char | '#' | '*' |
117+
| specialMask | String | Letter that will be replaced a upperCase char | '$' | '*' |
118+
| numberMask | String | Letter that will be replaced a upperCase char | '%' | '*' |
119+
168120
Testing
169121
-------
170122
To run the test, simply type `cd` into directory and run `npm test`. You
@@ -174,4 +126,4 @@ environment, and facilitate only unit testing.)
174126
175127
Contributing
176128
------------
177-
If you'd like to contribute, please fork this repository, change the default branch typing git checkout dev, make a new branch typing `git checkout -b branchName`, make your changes, make `git push -u origin branchName` and then submit a pull-request.
129+
If you'd like to contribute, please fork this repository, change the branch typing `git checkout dev`, make a new branch typing `git checkout -b branchName`, make your changes, make a push typing `git push -u origin branchName` and then submit a pull-request.

0 commit comments

Comments
 (0)