High-performance Scrypt wrapper for .NET with native SIMD-optimized bindings
$ dotnet add package nebulae.dotScryptdotScrypt is a high-performance .NET wrapper for Colin Percival's reference scrypt key derivation function, built for security, portability, and full parameter control.
This library provides native, optimized builds for Windows, Linux, and macOS (including Apple Silicon) with zero external dependencies.
dotScrypt enables direct access to scrypt_kdf() via Scrypt.Hash() through an idiomatic .NET interface, making it ideal for password hashing and cryptographic key derivation in AOT-compatible applications. Additional ergonomic wrappers have been added to: (1) encode the kdf parameters, salt, & password hash; and (2) verify those hashes against a supplied password.
A full test suite is provided in the Github repository, ensuring correctness and performance across all supported platforms.
.dll, .so, .dylibFor general usage, it is recommended to use the encoded string output for password hashing. If you do so you can use the built-in verification functions. Otherwise, you must re-compute the hash using the same original settings and compare the raw hashes yourself.
Scrypt.HashPassword() defaults to the current OWASP recommended parameters, but you can override any and all parameters as needed.
The following example demonstrates how to hash a password and verify it:
using nebulae.dotScrypt;
// Hash the password with full parameter control
string encoded = Scrypt.HashPassword(
password: "correct horse battery staple",
hashLength: 64,
saltLength: 16,
N: 131072, // CPU/memory cost (2^17)
r: 8, // block size
p: 1 // parallelism
);
// Store `encoded` in your database
// Later, verify a login attempt
bool isValid = Scrypt.Verify("correct horse battery staple", encoded);
Console.WriteLine(isValid ? "Password is valid" : "Invalid password");
You can install the package via NuGet:
$ dotnet add package nebulae.dotScrypt
Or via git:
$ git clone https://github.com/nebulaeonline/dotScrypt.git
$ cd dotScrypt
$ dotnet build
MIT
The library is feature complete and stable, but if you have any feature requests, suggestions, or concerns, please open an issue on the GitHub repository. Contributions are welcome.