Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to allow integration with other plugins #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
35 changes: 27 additions & 8 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ to save space, since my password policy doesn't allow anything shorter anyway.

Created by Erik Brännström.

Refactored by David Haslem to allow integration with jquery.validation

Options
-------
Expand All @@ -26,17 +27,35 @@ Options
- functions : Array of functions that receive the current entropy and password.
Must return a value that will replace the current value.
Options are merged with defaults.
- strings : Array with six elements, setting the result string.
- classes : Array with six elements, setting the class of the display element
based on the strength.
- thresholds : Array with thresholds counts, defining cutoffs for
each classification
- strings : Array with same length as thresholds, setting the result string.
- classes : Array with same length as thresholds, setting the class of the
display element based on the strength.
- blacklist : Array containing blacklisted words that should not be used as
passwords. Options are merged with defaults.

Example


Examples
-------
`$('input[type=password]').passwordEntropy({
'display' : 'div.result'
});`

$('input[type=password]').passwordEntropy({
'display' : 'div.result'
});

// Standalone usage
var tester = $.entropyTestFactory();
var entropy = tester.test('Foobar123');
var classification = tester.classify(entropy);
alert('Foobar123 has an entropy of '+entropy+' which is level '+classification);
alert('Classification is '+tester.messageForClass(classification));

It is possible to integrate the standalone tester into other jquery
plugins. An example is available here:

https://github.com/therabidbanana/jQuery-Password-Entropy/tree/validation-demo


License
-------
Expand All @@ -58,4 +77,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
24 changes: 20 additions & 4 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,31 @@
<script src="jquery.entropy.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('input[type=password]').passwordEntropy();
$('input#standalone').passwordEntropy();
});
</script>

<style>
input{
font-size: 18px;
padding: 0.2em;
border-radius: 0.5em;
border: 1px solid #bbb;
width: 300px;
}
.wrapper{
position: relative;
width: 300px;
}
label{
clear: both;
}
</style>
</head>
<body>

<h1>jQuery Password Entropy</h1>
<input type="password" />
<input type="password" id="standalone"/>
<div class="strength"></div>

</body>
</html>
</html>
Loading