You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately rust-crypto’s implementation of PBKDF2 is not properly optimized: it does not adheres to the loop inlines and buffering used in [modern implementations](https://jbp.io/2015/08/11/pbkdf2-performance-matters/). The package [fastpbkdf2](https://github.com/ctz/rust-fastpbkdf2) uses a C-binding of a [library](https://github.com/ctz/fastpbkdf2) that requires OpenSSL.
35
+
36
+
### Instalation
37
+
38
+
Add the dependency to your `Cargo.toml` declaring the feature:
39
+
40
+
```toml
41
+
[dependencies.djangohashers]
42
+
version = "0.2.0"
43
+
features = ["fpbkdf2"]
44
+
```
45
+
46
+
You need to install OpenSSL and set the environment variable to make it visible to the compiler; this changes depending on the operation system and package manager, for example, in OS X with MacPorts you may need to do something like this:
47
+
48
+
```
49
+
$ sudo port install openssl
50
+
$ CFLAGS="-I/opt/local/include" cargo ...
51
+
```
52
+
53
+
For other OSs and package managers, [follow the guide](https://cryptography.io/en/latest/installation/) of how to install Python’s **Cryptography** dependencies, that also links against OpenSSL.
54
+
55
+
### Performance
56
+
57
+
Method | Encode or Check | Performance
58
+
------- | --------------- | -------
59
+
Django 1.9.4 | 29.5ms | Baseline
60
+
djangohashers with rust-crypto 0.2.34 (default) | 41.7ms | 41% slower
61
+
djangohashers with fastpbkdf2 0.1.0 | 23.1ms | 28% faster
62
+
63
+
Notes:
64
+
65
+
* Best of 5 rounds of 100 events.
66
+
* Built with `--release`.
67
+
* PBKDF2 using SHA256 and iteration count set to 24000.
68
+
* Django version tested with CPython 3.5.1
69
+
* Rust/fastpbkdf2 version tested with Rust 1.6.0 and OpenSSL 1.0.2g.
70
+
* iMac Mid 2010 with an Intel Core i3 3.2Ghz and 16GB of RAM, running OS X 10.11.3.
71
+
72
+
32
73
## Compatibility
33
74
34
75
DjangoHashers passes all relevant unit tests from Django 1.9, there is even a [line-by-line translation](https://github.com/Racum/rust-djangohashers/blob/master/tests/django.rs) of [tests/auth_tests/test_hashers.py](https://github.com/django/django/blob/e403f22/tests/auth_tests/test_hashers.py).
0 commit comments