[go: nahoru, domu]

tree: e3e1395be7f0d3f43e8113624e42e582e1080484 [path history] [tgz]
  1. data-scripts/
  2. native-src/
  3. patches/
  4. test/
  5. BUILD.gn
  6. DEPS
  7. DIR_METADATA
  8. LICENSE.txt
  9. OWNERS
  10. README.chromium
  11. README.md
third_party/zxcvbn-cpp/README.md

zxcvbn-cpp

This is a C++ port of zxcvbn, an advanced password strength estimation library. For more details on how zxcvbn works and its advantages, check out the blog post.

This port is a direct translation of the original CoffeeScript source. This allows this port to easily stay in sync with the original source. Additionally, this port uses the same exact test scripts from the original with the help of emscripten.

This port also provides C, Python, and JS bindings from the same codebase.

Python Bindings

Build

$ python setup.py install

Use

>>> import zxcvbncpp
>>> print(zxcvbncpp.password_strength("Tr0ub4dour&3"))

JS Bindings

Build

Building the JS bindings requires a POSIX environment, including make, and Emscripten.

First make sure emcc is in your $PATH. You can do so using the Emscripten Portable SDK as follows:

$ source /path/to/emsdk_portable/emsdk_env.sh

Then simply run:

$ RELEASE=1 make -f jsmakefile lib/zxcvbn.js

Use

Add this script to your index.html:

<script src="path/to/zxcvbn.js"></script>

To make sure it loaded properly, open in a browser and type zxcvbn('Tr0ub4dour&3') into the console. For more information on how to use the JS port see the original documentation.

Use From Node

Usage from node is straight-forward:

var zxcvbn = require("./path/to/zxcvbn.js");
console.log(zxcvbn("Tr0ub4dour&3"));

How to build for your C/C++ project

Adapt these instructions to your build environment.

First generate adjacency graphs and frequency lists:

$ python ./data-scripts/build_frequency_lists.py ./data ./native-src/zxcvbn _frequency_lists.hpp
$ python ./data-scripts/build_frequency_lists.py ./data ./native-src/zxcvbn _frequency_lists.cpp
$ python ./data-scripts/build_keyboard_adjacency_graphs.py ./native-src/zxcvbn/adjacency_graphs.hpp
$ python ./data-scripts/build_keyboard_adjacency_graphs.py ./native-src/zxcvbn/adjacency_graphs.cpp

Add /absolute_path/to/zxcvbn-repo/native-src to your include path, then build all the .cpp files in /absolute_path/to/zxcvbn-repo/native-src/zxcvbn. Make sure you use the -std=c++14 compiler flag.

Testing

zxcvbn-cpp uses the test scripts from the original codebase, this makes it easy to verify that it is 100% compatible with the original. In addition to requiring a POSIX environment and Emscripten, testing also requires a NodeJS environment. Here's how you set it up:

$ npm install

Then to run the tests:

$ make -f jsmakefile test

Development

Bug reports and pull requests welcome!

Please note zxcvbn-cpp is written using modern C++14 techniques, no passing around stray pointers!