password-analyzer
v0.0.3
Published
Passwords Analyzer is an API developed to aid in analysis of password lists
Downloads
14
Readme
Password Analyzer
Passwords Analyzer is an API developed to aid in analysis of password lists.
It allows to analyze existing passwords and based on the analysis system password requirements can be changed (say, increase minimum password length or password complexity by requiring special characters) in order to improve system security.
Usage
var analyzer = require('password-analyzer');
var passwordAnalyzer = new analyzer.PasswordAnalyzer();
// Setup groups and analyzers for each group
passwordAnalyzer.addGroup('Character sets', ['numeric', 'loweralpha', 'upperalpha']);
passwordAnalyzer.addGroup('Months', ['months']);
// Sample passwords
var passwords = [ '123456', 'abcdef', 'foobar', 'ABC', 'January' ];
passwords.forEach(passwordAnalyzer.analyze.bind(passwordAnalyzer));
// returns object with results of passwords analysis
passwordAnalyzer.getResults();
The addGroup
function accepts two parameters:
- a string specifying a group name - that name will appear in an analysis results object
- an array or a single analyzer which can be:
- a string representing a pre-defined analyzer code (you can find analyzer codes below)
- an analyzer constructor (function) - a new analyzer will be instantiated using the given constructor
- an analyzer instance
Example of password analysis results:
{
total: 5, // total number of anlyzed passwords
groups: [ // All analysis groups
{
// Group name
name: 'Character sets',
// Analyzers for the given group
analyzers:[
// Analyzer code (id) and number of passwords matching rules of the given analyzer
{ code: 'numeric', count: 1 },
{ code: 'loweralpha', count: 2 },
{ code: 'upperalpha', count: 1 }
]
}, {
name: 'Months',
analyzers: [ { code: 'january', count: 1 } ]
}
]};
Available Analyzers
AllCharsAnalyzer
- (code:all
)Analyzer
- base analyzer - it is can be extended to create other more specialized analyzersLowerAlphaAnalyzer
- (code:loweralpha
) checks if a password is composed of lowercase letters onlyLowerAlphaNumAnalyzer
- (codeloweralphanum
) checks if a password is composed of lowercase letters and numbers onlyLowerAlphaSpecialAnalyzer
- (codeloweralphaspecial
) checks if a password is composed of lowercase and special characters onlyLowerAlphaSpecialNumAnalyzer
- (codeloweralphaspecialnum
) checks if a password is composed of: lowercase, special and numbers onlyMaskAnalyzer
- checks if a passwords is matched by a specific mask (see details below)MixedAlphaAnalyzer
- (code:mixedalpha
) checks if a password is composed of letters onlyMixedAlphaNumAnalyzer
- (codemixedalphanum
) checks if a password is composed of upper and lowercase letters onlyMixedAlphaSpecialAnalyzer
- (codemixedalphaspecial
) checks if a password is composed of: uppercase, lowercase and special characters onlyMonthsAnalyzer
- (code:months
) checks if a password is composed of English month names (case insensitive) onlyNumericAnalyzer
- (code:numeric
) checks if a password is composed of digits onlyPasswordLengthAnalyzer
- (code:length
) performs password length analysisRegexAnalyzer
- regular expression analyzer - perform password analysis based on configured regular expressions (password matching)SpecialAnalyzer
- (code:special
) checks if a password is composed of special characters onlySpecialNumAnalyzer
- (code:specialnum
) checks if a password is composed of digits and special characters onlyUpperAlphaAnalyzer
- (code:upperalpha
) checks if a password is composed of capital letters onlyUpperAlphaNumAnalyzer
- (code:upperalphanum
) checks if a password is composed of capital letters and digits onlyUpperAlphaSpecialAnalyzer
- (code:upperalphaspecial
) checks if a password is composed of capital letters and special characters onlyUpperAlphaSpecialNumAnalyzer
- (code:upperalphaspecialnum
) checks if a password is composed of: capital letters, special characters and digits only
MaskAnalyzer
Mask analyzer checks if a password is matched by a specific mask. The matching mask can be composed of letters and some masks as follows:
?l
- matches a single lowercase character?u
- matches a single uppercase character?d
- matches a single digit?s
- matches a single special character i.e. one of:!"#$%&'()*+,-./:;<=>?@[\]^_``{|}~«space»
?a
- matches any single characters i.e.?l
or?u
or?d
or?s
So a password like this foo123 would be matched by the following mask: ?l?l?l?d?d?d
.
Author
Written by Tom Pawlak - Blog
License
Copyright (c) 2014 Tom Pawlak
MIT License : https://blog.abelotech.com/mit-license/