scrypt, a Password-Based Key Derivation Function from Colin Percival, from version 1.1.6 of his library.
For general background on what scrypt
is, and why it's useful, see
these slides (PDF)
and Colin Percival's page on
scrypt.
- Install C++ build tools from https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15
- Select Build Tools and C++ CLI option and execute the installation
- Add environment variable
INCLUDE
with valueC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt;
- Add environment variable
LIB
with valueC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x64;
- Add
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\bin\Hostx64\x64
to environment vairiablePATH
- If while compiling there is an error while linking, execute
which link
verify if this is pointing to visual studio build tools folder. If not rename the other linker that is being fetched from the path.
The entry points are erlscrypt:scrypt/6
and erlscrypt:scrypt/7
.
Atom nif
can be passed as optional first parameter to gain some marginal speed over
port.
Both Passwd
and Salt
must be binaries. N
, R
, and P
control
the complexity of the password-derivation process. Buflen
is the
number of bytes of key material to generate.
For some good choices for N
, R
and P
, see the
paper.
Example:
1> erlscrypt:scrypt(<<"pleaseletmein">>, <<"SodiumChloride">>, 16384, 8, 1, 64).
<<112,35,189,203,58,253,115,72,70,28,6,205,129,253,56,235,
253,168,251,186,144,79,142,62,169,181,67,246,84,...>>
2> erlscrypt:scrypt(nif,<<"pleaseletmein">>, <<"SodiumChloride">>, 16384, 8, 1, 64).
<<112,35,189,203,58,253,115,72,70,28,6,205,129,253,56,235,
253,168,251,186,144,79,142,62,169,181,67,246,84,...>>
Please see LICENSE for more details