Skip to content

Commit daefb21

Browse files
committed
fixes
1 parent fda8208 commit daefb21

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# generate-strings
1+
# generate-strings dev branch
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.
@@ -81,27 +81,15 @@ const settings = {
8181
mode: 'random',
8282
// set the mode. Allows "random", "mask" and "password"
8383
84-
upperCase: true,
85-
// set a boolean value to generate strings with upperCase characters
86-
8784
upperCases: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
8885
// upperCases characters
8986
90-
lowerCase: true,
91-
// set a boolean value to generate strings with lowerCase characters
92-
9387
lowerCases: 'abcdefghijklmnopqrstuvwxyz',
9488
// lowerCase characters
9589
96-
special: false,
97-
// set a boolean value to generate strings with special characters
98-
9990
specials: '!@#$%&*()=[]{}',
10091
// special characters
10192
102-
number: true,
103-
// set a boolean value to generate strings with numbers
104-
10593
numbers: '0123456789',
10694
// numbers
10795
@@ -113,14 +101,26 @@ const settings = {
113101
length: 8,
114102
// length of the strings
115103
104+
upperCase: true,
105+
// set a boolean value to generate strings with upperCase characters
106+
107+
lowerCase: true,
108+
// set a boolean value to generate strings with lowerCase characters
109+
110+
special: false,
111+
// set a boolean value to generate strings with special characters
112+
113+
number: true,
114+
// set a boolean value to generate strings with numbers
115+
116116
/*
117117
*************************************************
118118
Settings for password mode
119119
*************************************************
120120
*/
121121
showStrength: false,
122122
// Shows the password strength
123-
//like: strength: high. Possible results: unacceptable, terrible, medium, good and high.
123+
// like: strength: high. Possible results: unacceptable, terrible, medium, good and high.
124124
125125
firstCharType: 'random',
126126
// set the type of first character when generate a password
@@ -157,4 +157,4 @@ environment, and facilitate only unit testing.)
157157

158158
Contributing
159159
------------
160-
If you'd like to contribute, please fork this repository, type git checkout dev and make your changes, and then submit a pull-request.
160+
If you'd like to contribute, please fork this repository, make your changes, and then submit a pull-request.

dist/generate-strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports =
4040
/***/ 977:
4141
/***/ (function(__unusedmodule, exports) {
4242

43-
(function(a,b){'function'==typeof define&&define.amd?define([],b): true?exports.generate=b:undefined})(this,function(a={}){let b='',c=a.amount===void 0?1:a.amount;const d=!(a.upperCase!==void 0)||a.upperCase,e=a.upperCases===void 0?'ABCDEFGHIJKLMNOPQRSTUVWXYZ':a.upperCases,f=!(a.lowerCase!==void 0)||a.lowerCase,g=a.lowerCases===void 0?'abcdefghijklmnopqrstuvwxyz':a.lowerCases,h=a.special!==void 0&&a.special,j=a.specials=a.specials,k=!(a.number!==void 0)||a.number,l=a.numbers===void 0?'0123456789':a.numbers,m=a.mode===void 0?'random':a.mode;if(!(0<c))throw new Error('Amount should be > 0');if('random'===m){const n=void 0===a.length?8:a.length,o=(!0===d?e:'')+(!0===f?g:'')+(!0===h?j:'')+(!0===k?l:''),p=[];do{for(let q=0;q<n;q++)b+=o[parseInt(Math.random()*o.length)];p.push(b),b='',c--}while(0<c);return 1===p.length?p[0]:p}if('password'===m){const n=void 0===a.length?8:a.length,o=void 0!==a.showStrength&&a.showStrength,p=void 0===a.firstCharType?'random':a.firstCharType,q=(!0===d?e:'')+(!0===f?g:'')+(!0===h?j:'')+(!0===k?l:''),r=[];if(6>n)throw new Error('Length should be > 5');do{b+='upperCase'===p?e[parseInt(Math.random()*e.length)]:'lowerCase'===p?g[parseInt(Math.random()*g.length)]:'special'===p?j[parseInt(Math.random()*j.length)]:'number'===p?l[parseInt(Math.random()*l.length)]:q[parseInt(Math.random()*q.length)];for(let t,s=0;s<n-1;s++){for(t=q[parseInt(Math.random()*q.length)];b[s]===t;)t=q[parseInt(Math.random()*q.length)];b+=t}o?r.push({password:b,strength:checkStrength(b)}):r.push(b),b='',c--}while(0<c);return 1===r.length?r[0]:r}if('mask'===m){const n=void 0===a.mask?'@#$%-@#$%-@#$%-@#$%':a.mask,o=[];if(0===n.length)throw new Error('Mask wrong. Please do something like "@#$%-@#$%-#@$%-@#$%"');do{for(let p=0;p<n.length;p++)b+='@'===n[p]?e[parseInt(Math.random()*e.length)]:'#'===n[p]?g[parseInt(Math.random()*g.length)]:'$'===n[p]?j[parseInt(Math.random()*j.length)]:'%'===n[p]?l[parseInt(Math.random()*l.length)]:n[p];o.push(b),b='',c--}while(0<c);return 1===o.length?o[0]:o}throw new Error('Wrong mode, please set "mode" to "random" or "password" or "mask"')});function checkStrength(a=String){let b=0;b+=10*Math.min(6,a.length),b+=5*Math.min(2,a.length-a.replace(/[A-Z]/g,'').length),b+=5*Math.min(2,a.length-a.replace(/[a-z]/g,'').length),b+=5*Math.min(2,a.length-a.replace(/[0-9]/g,'').length),b+=5*Math.min(2,a.replace(/[a-zA-Z0-9]/g,'').length);for(let c=1;c<a.length;c++)if(a[c-1]===a[c]){b-=30;break}return 50>b?'unacceptable':60>b?'terrible':80>b?'medium':100>b?'good':'high'}
43+
'use-strict';(function(a,b){'function'==typeof define&&define.amd?define([],b): true?exports.generate=b:undefined})(this,function(a={}){let b='',c=a.amount===void 0?1:a.amount;const d=!(a.upperCase!==void 0)||a.upperCase,e=a.upperCases===void 0?'ABCDEFGHIJKLMNOPQRSTUVWXYZ':a.upperCases,f=!(a.lowerCase!==void 0)||a.lowerCase,g=a.lowerCases===void 0?'abcdefghijklmnopqrstuvwxyz':a.lowerCases,h=a.special!==void 0&&a.special,j=a.specials===void 0?'!@#$%&*()=[]{}':a.specials,k=!(a.number!==void 0)||a.number,l=a.numbers===void 0?'0123456789':a.numbers,m=a.mode===void 0?'random':a.mode;if(!(0<c))throw new Error('Amount should be > 0');if('random'===m){const n=void 0===a.length?8:a.length,o=(!0===d?e:'')+(!0===f?g:'')+(!0===h?j:'')+(!0===k?l:''),p=[];if(''===o)throw new Error('You must set at least 1 character type for generate a random string');do{for(let q=0;q<n;q++)b+=o[parseInt(Math.random()*o.length)];p.push(b),b='',c--}while(0<c);return 1===p.length?p[0]:p}if('password'===m){const n=void 0===a.length?8:a.length,o=void 0!==a.showStrength&&a.showStrength,p=void 0===a.firstCharType?'random':a.firstCharType,q=(!0===d?e:'')+(!0===f?g:'')+(!0===h?j:'')+(!0===k?l:''),r=[];if(''===q)throw new Error('You must set at least 1 character type for generate a password');if(6>n)throw new Error('Length should be > 5');do{if('upperCase'===p){if(''===e)throw new Error('Set at least 1 character for upperCase');b+=e[parseInt(Math.random()*e.length)]}else if('lowerCase'===p){if(''===g)throw new Error('Set at least 1 character for lowerCase');b+=g[parseInt(Math.random()*g.length)]}else if('special'===p){if(''===j)throw new Error('Set at least 1 character for special');b+=j[parseInt(Math.random()*j.length)]}else if('number'===p){if(''===l)throw new Error('Set at least 1 character for number');b+=l[parseInt(Math.random()*l.length)]}else b+=q[parseInt(Math.random()*q.length)];for(let t,s=0;s<n-1;s++){for(t=q[parseInt(Math.random()*q.length)];b[s]===t;)t=q[parseInt(Math.random()*q.length)];b+=t}o?r.push({password:b,strength:checkStrength(b)}):r.push(b),b='',c--}while(0<c);return 1===r.length?r[0]:r}if('mask'===m){const n=void 0===a.mask?'@#$%-@#$%-@#$%-@#$%':a.mask,o=[];if(0===n.length)throw new Error('Mask wrong. Please do something like "@#$%-@#$%-#@$%-@#$%"');do{for(let p=0;p<n.length;p++)if('@'===n[p]){if(''===e)throw new Error('Set at least 1 character for upperCases');b+=e[parseInt(Math.random()*e.length)]}else if('#'===n[p]){if(''===g)throw new Error('Set at least 1 character for lowerCases');b+=g[parseInt(Math.random()*g.length)]}else if('$'===n[p]){if(''===j)throw new Error('Set at least 1 character for specials');b+=j[parseInt(Math.random()*j.length)]}else if('%'===n[p]){if(''===l)throw new Error('Set at least 1 character for numbers');b+=l[parseInt(Math.random()*l.length)]}else b+=n[p];o.push(b),b='',c--}while(0<c);return 1===o.length?o[0]:o}throw new Error('Wrong mode, please set "mode" to "random" or "password" or "mask"')});function checkStrength(a=String){let b=0;b+=10*Math.min(6,a.length),b+=5*Math.min(2,a.length-a.replace(/[A-Z]/g,'').length),b+=5*Math.min(2,a.length-a.replace(/[a-z]/g,'').length),b+=5*Math.min(2,a.length-a.replace(/[0-9]/g,'').length),b+=5*Math.min(2,a.replace(/[a-zA-Z0-9]/g,'').length);for(let c=1;c<a.length;c++)if(a[c-1]===a[c]){b-=30;break}return 50>b?'unacceptable':60>b?'terrible':80>b?'medium':100>b?'good':'high'}
4444

4545
/***/ })
4646

generate-strings.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generate-strings",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Generate random strings, strings with mask and strength passwords with password-strength tester",
55
"main": "generate-strings.js",
66
"scripts": {
@@ -18,7 +18,9 @@
1818
"password-strength",
1919
"random",
2020
"front-end",
21-
"backend"
21+
"backend",
22+
"generate",
23+
"strings-manipulation"
2224
],
2325
"author": "Lucas Naja",
2426
"license": "MIT",

0 commit comments

Comments
 (0)