Is your password safe? This is a JavaScript fork of safe.
Install with npm:
$ npm install safe.js --save
Install with component(1):
$ component install lepture/safe.js
You can also grab the standalone file:
$ curl https://github.com/lepture/safe.js/blob/master/safe.js
var safe = require('safe.js');
Check the safety strength of the password:
safe('password')
// {valid: false, strength: 'simple', message: 'password is too common'}
Set the minimal length of the password, default is 4.
safe.min = 6
Words hash map which are commonly used. Many thanks to Mark Burnett for the great work on 10000 Top Passwords.
In Node.js environment, safe.words is loaded with the default data. In browsers, you need to load data yourself.
Here are the tips for browser integration. If you are using the standalone version of safe.js, you need to download the words.json yourself. If you are using component, it is included in the component.json.
Load words data with an AJAX request:
if (!safe.wordsLoaded) {
// only load data when words not loaded
request('path/to/words.json', function(words) {
safe.cache(words);
});
}
Cache the words in browser's local storage. Words should be a map/dict object.
Safe.js will load data from local storage automatically. If data is loaded, this property will be true.
BSD