• Stars
    star
    308
  • Rank 131,154 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 11 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ruby port of Dropbox's zxcvbn javascript lib

zxcvbn-ruby

This is a Ruby port of Dropbox's zxcvbn.js JavaScript library.

Development status CI Status

zxcvbn-ruby is considered stable and is used in projects around Envato.

After checking out the repository, run bundle install to install dependencies. Then, run rake spec to run the tests.

To install this gem onto your local machine, run bundle exec rake install.

To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Getting started Gem version Gem downloads

Add the following to your project's Gemfile:

gem 'zxcvbn-ruby', require: 'zxcvbn'

Example usage:

$ irb
>> require 'zxcvbn'
=> true
>> pp Zxcvbn.test('@lfred2004', ['alfred'])
#<Zxcvbn::Score:0x00007f7f590610c8
 @calc_time=0.0055760000250302255,
 @crack_time=0.012,
 @crack_time_display="instant",
 @entropy=7.895,
 @feedback=
  #<Zxcvbn::Feedback:0x00007f7f59060150
   @suggestions=
    ["Add another word or two. Uncommon words are better.",
     "Predictable substitutions like '@' instead of 'a' don't help very much"],
   @warning=nil>,
 @match_sequence=
  [#<Zxcvbn::Match matched_word="alfred", token="@lfred", i=0, j=5, rank=1, pattern="dictionary", dictionary_name="user_inputs", l33t=true, sub={"@"=>"a"}, sub_display="@ -> a", base_entropy=0.0, uppercase_entropy=0.0, l33t_entropy=1, entropy=1.0>,
   #<Zxcvbn::Match i=6, j=9, token="2004", pattern="year", entropy=6.894817763307944>],
 @password="@lfred2004",
 @score=0>
=> #<Zxcvbn::Score:0x00007f7f59060150>
>> pp Zxcvbn.test('asdfghju7654rewq', ['alfred'])
#<Zxcvbn::Score:0x00007f7f5a9e9248
 @calc_time=0.007504999986849725,
 @crack_time=46159.451,
 @crack_time_display="14 hours",
 @entropy=29.782,
 @feedback=
  #<Zxcvbn::Feedback:0x00007f7f5a9e9130
   @suggestions=
    ["Add another word or two. Uncommon words are better.",
     "Use a longer keyboard pattern with more turns"],
   @warning="Short keyboard patterns are easy to guess">,
 @match_sequence=
  [#<Zxcvbn::Match pattern="spatial", i=0, j=15, token="asdfghju7654rewq", graph="qwerty", turns=5, shifted_count=0, entropy=29.7820508329166>],
 @password="asdfghju7654rewq",
 @score=2>
=> #<Zxcvbn::Score:0x00007f7f5a9e9248>

Testing Multiple Passwords

The dictionaries used for password strength testing are loaded each request to Zxcvbn.test. If you you'd prefer to persist the dictionaries in memory (approx 20MB RSS) to perform lots of password tests in succession then you can use the Zxcvbn::Tester API:

$ irb
>> require 'zxcvbn'
=> true
>> tester = Zxcvbn::Tester.new
=> #<Zxcvbn::Tester:0x3fe99d869aa4>
>> pp tester.test('@lfred2004', ['alfred'])
#<Zxcvbn::Score:0x00007f7f586fcf50
 @calc_time=0.00631899997824803,
 @crack_time=0.012,
 @crack_time_display="instant",
 @entropy=7.895,
 @feedback=
  #<Zxcvbn::Feedback:0x00007f7f586fcac8
   @suggestions=
    ["Add another word or two. Uncommon words are better.",
     "Predictable substitutions like '@' instead of 'a' don't help very much"],
   @warning=nil>,
 @match_sequence=
  [#<Zxcvbn::Match matched_word="alfred", token="@lfred", i=0, j=5, rank=1, pattern="dictionary", dictionary_name="user_inputs", l33t=true, sub={"@"=>"a"}, sub_display="@ -> a", base_entropy=0.0, uppercase_entropy=0.0, l33t_entropy=1, entropy=1.0>,
   #<Zxcvbn::Match i=6, j=9, token="2004", pattern="year", entropy=6.894817763307944>],
 @password="@lfred2004",
 @score=0>
=> #<Zxcvbn::Score:0x00007f7f586fcf50>
>> pp tester.test('@lfred2004', ['alfred'])
#<Zxcvbn::Score:0x00007f7f56d57438
 @calc_time=0.001986999996006489,
 @crack_time=0.012,
 @crack_time_display="instant",
 @entropy=7.895,
 @feedback=
  #<Zxcvbn::Feedback:0x00007f7f56d56bf0
   @suggestions=
    ["Add another word or two. Uncommon words are better.",
     "Predictable substitutions like '@' instead of 'a' don't help very much"],
   @warning=nil>,
 @match_sequence=
  [#<Zxcvbn::Match matched_word="alfred", token="@lfred", i=0, j=5, rank=1, pattern="dictionary", dictionary_name="user_inputs", l33t=true, sub={"@"=>"a"}, sub_display="@ -> a", base_entropy=0.0, uppercase_entropy=0.0, l33t_entropy=1, entropy=1.0>,
   #<Zxcvbn::Match i=6, j=9, token="2004", pattern="year", entropy=6.894817763307944>],
 @password="@lfred2004",
 @score=0>
=> #<Zxcvbn::Score:0x00007f7f56d57438>

Note: Storing the entropy of an encrypted or hashed value provides information that can make cracking the value orders of magnitude easier for an attacker. For this reason we advise you not to store the results of Zxcvbn::Tester#test. Further reading: A Tale of Security Gone Wrong.

Contact

Maintainers

Authors

License license

zxcvbn-ruby uses MIT license, the same as zxcvbn.js itself. See LICENSE.txt for details.

Code of Conduct

We welcome contribution from everyone. Read more about it in CODE_OF_CONDUCT.md.

Contributing PRs welcome

For bug fixes, documentation changes, and features:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

For larger new features: Do everything as above, but first also make contact with the project maintainers to be sure your change fits with the project direction and you won't be wasting effort going in the wrong direction.

About code with heart by Envato

This project is maintained by the Envato engineering team and funded by Envato.

Envato logo

Encouraging the use and creation of open source software is one of the ways we serve our community. See our other projects or come work with us where you'll find an incredibly diverse, intelligent and capable group of people who help make our company succeed and make our workplace fun, friendly and happy.

More Repositories

1

double_entry

A double-entry accounting system for Ruby applications.
Ruby
403
star
2

envato-wordpress-toolkit

Wordpress toolkit for authors of items available from the Envato Market sites.
PHP
373
star
3

wp-envato-market

WordPress Theme & Plugin management for the Envato Market.
PHP
335
star
4

stack_master

The missing CloudFormation tool
Ruby
286
star
5

envato-theme-check

The WordPress Theme Check plugin for Envato
PHP
201
star
6

aldous

Brave New World for Rails with more cohesion, less coupling and greater development speed for all
Ruby
128
star
7

pagerduty

📟 A Ruby gem for talking to the Pagerduty Events API
Ruby
100
star
8

event_sourcery

A library for building event sourced applications in Ruby
Ruby
84
star
9

safe_shell

Safely execute shell commands and get their output.
Ruby
74
star
10

react-breakpoints

Respond to changes in a DOM element's size. With React Breakpoints, element queries are no longer "web design's unicorn" 🦄
TypeScript
72
star
11

envato-wordpress-toolkit-library

WordPress Toolkit Library for Envato Marketplace hosted items
PHP
71
star
12

lumberg

Ruby library for the WHM & cPanel API; It's not a half day or anything like that.
Ruby
56
star
13

rails_4_session_flash_backport

Rails 4 Session Flash Backport
Ruby
52
star
14

ami-spec

Acceptance testing your AMIs
Ruby
49
star
15

heroku-deploy

Complete zero downtime deploys for Rails applications on Heroku
Ruby
41
star
16

rack-ecg

Health check page as Rack middleware
Ruby
39
star
17

splinter

Chop your specs in half with Splinter, a collection of helpers to submit forms with RSpec and Capybara.
Ruby
30
star
18

unwrappr

🍫 bundle update PRs: Automated. Annotated. Announced daily.
Ruby
27
star
19

extensions-sketch-plugin

Envato Elements - Sketch Plugin (Beta)
JavaScript
26
star
20

exiv2

A simple wrapper around exiv2
Ruby
25
star
21

jwt_signed_request

Request signing and verification made easy
Ruby
24
star
22

iodized

Iodine rich feature toggling. Lack of iodine can lead to development delays, and stunted growth.
Elixir
21
star
23

react-ab-experiment

A/B Experiment React Component
JavaScript
18
star
24

event_sourcery_todo_app

Example event_sourcery app
Ruby
15
star
25

awsraw

Minimal AWS client
Ruby
14
star
26

moo_moo

Implements OpenSRS XML API
Ruby
14
star
27

create-react-icon

Convert one or multiple svg files into React component
JavaScript
13
star
28

aspect_ratio

Image aspect ratio calculation utility
Ruby
13
star
29

event_sourcery-postgres

Postgres event store implementation for EventSourcery
Ruby
13
star
30

github-pull-request-buildkite-plugin

Open Github pull requests via your Buildkite builds
Shell
12
star
31

cookie-consent

Some helper functions to deal with cookie-consent
TypeScript
11
star
32

knuckle_cluster

Gem to interrogate and connect to ECS clusters, Spot fleets and Autoscaling groups
Ruby
10
star
33

cloudformation_rspec

Test your CloudFormation templates
Ruby
10
star
34

aws-account-concierge

Opensource AWS account management tool
Ruby
9
star
35

flv

FLV Parser
Ruby
9
star
36

forked

Forked manages long running worker processes
Ruby
8
star
37

subvalid

Subjective validation for Plain Old Ruby Objects
Ruby
8
star
38

react-resize-observer-hook

Observe multiple DOM elements with a single ResizeObserver.
TypeScript
8
star
39

ejsonkms

Integrates EJSON with AWS KMS
Go
8
star
40

heroku-buildpack-libsodium

libsodium/rbnacl buildpack for Heroku
Shell
8
star
41

foundation-design-system-tokens

Design Tokens for the Foundation Design System
JavaScript
8
star
42

guide

Document your application with a living component library and styleguide
Ruby
8
star
43

studio-client-uploader

JavaScript
8
star
44

outatime

Choose versioned S3 files from a point in time.
Ruby
7
star
45

wp-image-size-limit

Wordpress plugin for limiting the image file size
PHP
7
star
46

aws-s3-sync-buildkite-plugin

Shell
7
star
47

rails_session_key_rotator

Graceful secret key rotation for the signed cookie store in Rails.
Ruby
6
star
48

babushka-deps

Ruby
6
star
49

lambda-deploy-buildkite-plugin

A Buildkite plugin to deploy AWS Lambda function code
Shell
6
star
50

encapsulate_as_money

Surprise me ;)
Ruby
6
star
51

double_entry-reporting

Reporting on Double Entry accounts and transfers
Ruby
6
star
52

medusa

The most beautiful parallel build system, evar.
JavaScript
5
star
53

hamburglar

Hamburglar helps you prevent fraudulent orders
Ruby
5
star
54

fake_aws

Ruby
5
star
55

market-api-gateway-js

JavaScript SDK for marketplace api-gateway
JavaScript
5
star
56

ejson_wrapper

Combines EJSON with AWS KMS
Ruby
5
star
57

bundle-update-buildkite-plugin

Update Ruby gem dependencies in a Buildkite build!
Shell
5
star
58

stop-the-line-buildkite-plugin

Stop Buildkite pipelines based on build meta-data values.
Shell
5
star
59

event_sourcery_generators

An opinionated CLI tool for building event-sourced Ruby services with EventSourcery
Ruby
4
star
60

imageresize

Image resizing for Envato Sites author tools
Go
4
star
61

packer-ami-copy-buildkite-plugin

A buildkite plugin which simplifies the process of building and copying an AMI with packer
Shell
4
star
62

create-datadog-event-buildkite-plugin

An experimental Buildkite plugin which creates Datadog events.
Shell
4
star
63

heroku-container-deploy-buildkite-plugin

Deploy pre-built docker images to Heroku using Heroku Container Registry
Shell
4
star
64

docker-cache-buildkite-plugin

Build a multi-stage compatible cache image and store it in S3
Shell
4
star
65

react-ab-experiment-example

React AB Experiment example app
JavaScript
4
star
66

barricade

better locking
Ruby
4
star
67

google-analytics-for-wordpress

WordPress.org Plugin Mirror
PHP
4
star
68

browser-privacy-checker

Handy React 🎣 module to check whether can use user cookie and similar technologies from browser
TypeScript
4
star
69

unwrappr-demo

Demonstrating the power of Unwrappr
Ruby
3
star
70

marketplace-stats-as-a-service

A little micro service to cache and expose Envato Marketplace stats(total items and total users)
JavaScript
3
star
71

puppet-hubot

Puppet
3
star
72

sprockets-resilience

Stop Rails from killing your site when assets aren't precompiled
Ruby
3
star
73

rack_fake_s3

Ruby
3
star
74

ejson2env-buildkite-plugin

A Buildkite plugin for exporting environment variables stored in ejson files using ejson2env
Shell
3
star
75

cloudformation-output-buildkite-plugin

Collects cloudformation output from an AWS stack and add them as environment variables
Shell
3
star
76

mandrill-merge

We all hate spam, but sometimes you need to get an important message out to a large group of people. Mandrill is great at allowing you to define templates, sending emails out, and keeping track of sends and responses. But how do you get the data from your database over to Mandrill quickly and easily? That's where MandrillMerge comes in...
Ruby
3
star
77

chisel-scripts

Chisel scripts created to debug any issues
Lua
2
star
78

siren-call

A gem for interacting with Siren style REST APIs
Ruby
2
star
79

backbone.proxy-view

A proxy view is an instance of Backbone.View that doesn't render any of its own HTML
CoffeeScript
2
star
80

iodized_ruby_client

Ruby
2
star
81

eventory

A new take on event sourcing in ruby
Ruby
2
star
82

docker-size-annotation-buildkite-plugin

Annotates the build with a docker image size
Shell
2
star
83

thrift-erlang

copy + paste of Apache thrift erlang lib. Mirrored here so it can be used for rebar/mix etc
Erlang
2
star
84

fancy-confluence

CSS
2
star
85

spot_build

Agents are transient, Jobs are forever
Ruby
2
star
86

logstash-filter-dynamo_enrich

Enrich Logstash events with data from DynamoDB
Ruby
2
star
87

batch_retry

Batch send data with retries and exponential backoff
Python
2
star
88

rack_request_ip_strategies

Replacement for Rack::Request#ip
Ruby
2
star
89

heartbeat

Heartbeat plugin that exposes an API to monitor internal services
Ruby
2
star
90

wordpress-https

A fork of an older version of wordpress-https plugin that disables some super-slow functionality.
PHP
2
star
91

backbone.autocomplete-view

A template driven autocomplete view for Backbone
CoffeeScript
2
star
92

build-failed-notify-slack-buildkite-plugin

@'s the creator of the failed build via a mapping file
Shell
2
star
93

swarm

Ruby
2
star
94

studio-asset-service-uploader

An uploader for the studio asset service
JavaScript
1
star
95

puppet_module_provider

Ruby
1
star
96

babel-plugin-postcss-cssmodules-transform

Babel Plugin Transform PostCSS and extract static CSS
JavaScript
1
star
97

studio-asset-service-client-js

A javascript client for the studio asset service
JavaScript
1
star
98

reproduce-fluentd-cascading-buffer

Reproduce cascading failure when Fluentd's internal memory buffer becomes full
Shell
1
star
99

virtellus

A smaller, faster, less powerful Virtus
Ruby
1
star
100

jquery-expander

A jQuery plugin that toggles classes on two elements
CoffeeScript
1
star