Skip to content

Commit c19377f

Browse files
committed
minified files
1 parent 0656daa commit c19377f

File tree

3 files changed

+3
-273
lines changed

3 files changed

+3
-273
lines changed

dist/generate-strings.js

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

43-
(function (root, generate) {
44-
if (typeof define === 'function' && define.amd)
45-
define([], generate);
46-
else if (true)
47-
exports.generate = generate
48-
else {}
49-
50-
})(this, function (obj = {}) {
51-
let str = '',
52-
amount = obj.amount === undefined ? 1 : obj.amount
53-
const upperCase = obj.upperCase === undefined ? true : obj.upperCase,
54-
upperCases = obj.upperCases === undefined ? 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' : obj.upperCases,
55-
lowerCase = obj.lowerCase === undefined ? true : obj.lowerCase,
56-
lowerCases = obj.lowerCases === undefined ? 'abcdefghijklmnopqrstuvwxyz' : obj.lowerCases,
57-
special = obj.special === undefined ? false : obj.special,
58-
specials = obj.specials = undefined ? '!@#$%&*()=[]{}' : obj.specials,
59-
number = obj.number === undefined ? true : obj.number,
60-
numbers = obj.numbers === undefined ? '0123456789' : obj.numbers,
61-
mode = obj.mode === undefined ? 'random' : obj.mode
62-
63-
if (!(amount > 0))
64-
throw new Error('Amount should be > 0')
65-
66-
if (mode === 'random') {
67-
const length = obj.length === undefined ? 8 : obj.length,
68-
characters = (upperCase === true ? upperCases : '') + (lowerCase === true ? lowerCases : '') +
69-
(special === true ? specials : '') + (number === true ? numbers : ''),
70-
strings = []
71-
72-
do {
73-
for (let i = 0; i < length; i++)
74-
str += characters[parseInt(Math.random() * characters.length)]
75-
76-
strings.push(str)
77-
str = ''
78-
amount--
79-
} while (amount > 0)
80-
81-
return strings.length === 1 ? strings[0] : strings
82-
} else if (mode === 'password') {
83-
const length = obj.length === undefined ? 8 : obj.length,
84-
showStrength = obj.showStrength === undefined ? false : obj.showStrength,
85-
firstCharType = obj.firstCharType === undefined ? 'random' : obj.firstCharType,
86-
characters = (upperCase === true ? upperCases : '') + (lowerCase === true ? lowerCases : '') +
87-
(special === true ? specials : '') + (number === true ? numbers : ''),
88-
password = []
89-
90-
if (length < 6)
91-
throw new Error('Length should be > 5')
92-
93-
do {
94-
if (firstCharType === 'upperCase')
95-
str += upperCases[parseInt(Math.random() * upperCases.length)]
96-
else if (firstCharType === 'lowerCase')
97-
str += lowerCases[parseInt(Math.random() * lowerCases.length)]
98-
else if (firstCharType === 'special')
99-
str += specials[parseInt(Math.random() * specials.length)]
100-
else if (firstCharType === 'number')
101-
str += numbers[parseInt(Math.random() * numbers.length)]
102-
else str += characters[parseInt(Math.random() * characters.length)]
103-
104-
for (let i = 0; i < length; i++) {
105-
let char = characters[parseInt(Math.random() * characters.length)]
106-
107-
while (str[i] === char)
108-
char = characters[parseInt(Math.random() * characters.length)]
109-
110-
str += char
111-
}
112-
113-
if (showStrength)
114-
password.push({
115-
password: str,
116-
strength: checkStrength(str)
117-
})
118-
else password.push(str)
119-
120-
str = ''
121-
amount--
122-
} while (amount > 0)
123-
124-
return password.length === 1 ? password[0] : password
125-
} else if (mode === 'mask') {
126-
const mask = obj.mask === undefined ? '@#$%-@#$%-@#$%-@#$%' : obj.mask,
127-
strings = []
128-
129-
if (mask.length === 0)
130-
throw new Error('Mask wrong. Please do something like "@#$%-@#$%-#@$%-@#$%"')
131-
132-
do {
133-
for (let i = 0; i < mask.length; i++)
134-
if (mask[i] === '@')
135-
str += upperCases[parseInt(Math.random() * upperCases.length)]
136-
else if (mask[i] === '#')
137-
str += lowerCases[parseInt(Math.random() * lowerCases.length)]
138-
else if (mask[i] === '$')
139-
str += specials[parseInt(Math.random() * specials.length)]
140-
else if (mask[i] === '%')
141-
str += numbers[parseInt(Math.random() * numbers.length)]
142-
else str += mask[i]
143-
144-
strings.push(str)
145-
str = ''
146-
amount--
147-
} while (amount > 0)
148-
149-
return strings.length === 1 ? strings[0] : strings
150-
} else
151-
throw new Error('Wrong mode, please set "mode" to "random" or "password" or "mask"')
152-
})
153-
154-
function checkStrength(password = String) {
155-
let length = 0
156-
157-
length += Math.min(6, password.length) * 10
158-
length += Math.min(2, password.length - password.replace(/[A-Z]/g, '').length) * 5
159-
length += Math.min(2, password.length - password.replace(/[a-z]/g, '').length) * 5
160-
length += Math.min(2, password.length - password.replace(/[0-9]/g, '').length) * 5
161-
length += Math.min(2, password.replace(/[a-zA-Z0-9]/g, '').length) * 5
162-
163-
for (let i = 1; i < password.length; i++)
164-
if (password[i - 1] === password[i]) {
165-
length -= 30
166-
break
167-
}
168-
169-
if (length < 50)
170-
return 'unacceptable'
171-
else if (length < 60)
172-
return 'terrible'
173-
else if (length < 80)
174-
return 'medium'
175-
else if (length < 100)
176-
return 'good'
177-
else return 'high'
178-
}
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;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'}
17944

18045
/***/ })
18146

generate-strings.js

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generate-strings",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Generate random strings, strings with mask and strength passwords with password-strength tester",
55
"main": "generate-strings.js",
66
"scripts": {

0 commit comments

Comments
 (0)