yescrypt 1.0.15

dotnet add package yescrypt --version 1.0.15
NuGet\Install-Package yescrypt -Version 1.0.15
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="yescrypt" Version="1.0.15" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add yescrypt --version 1.0.15
#r "nuget: yescrypt, 1.0.15"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install yescrypt as a Cake Addin
#addin nuget:?package=yescrypt&version=1.0.15

// Install yescrypt as a Cake Tool
#tool nuget:?package=yescrypt&version=1.0.15

Build status nuget

yescrypt-net

.NET implementation of the yescrypt a password-based key derivation function (KDF) and password hashing scheme.

Packaging

Nuget package available here: https://www.nuget.org/packages/yescrypt

Usage

This implementation is suitable for simple validation of passwords against the yescrypt hash that can be found in the /etc/shadow file on modern Linux distos:

$ sudo cat /etc/shadow
...
testuser:$y$j9T$IZUrEbc9oo9gZ28EqoVjI.$HVWJnkX89URubQkrksozeEoBwresP91xRowRD4ynRE9:19389:0:99999:7:::
...

Using the yescrypt value from the line above, you can write code like this to validate testuser's password:

using Fasterlimit.Yescrypt

public static void main(string[] args)
{
    byte[] passwd = Encoding.UTF8.GetBytes("passw0rd");
    if (Yescrypt.CheckPasswd(passwd, "$y$j9T$IZUrEbc9oo9gZ28EqoVjI.$HVWJnkX89URubQkrksozeEoBwresP91xRowRD4ynRE9"))
    {
        Console.WriteLine("Correct");
    }
    else
    {
        Console.WriteLine("Incorrect");
    }
}

The Yescrypt class has two other useful methods:

  • Yescrypt.ChangePasswd(byte[] newpasswd, string encoded) -
    • Input: new password and yescrypt encoded string.
    • Output: yescrypt string with new salt and new password hash (using settings from the encoded input string)
  • Yescrypt.NewPasswd(byte[] newPasswd,YescryptSettings settings)
    • Input: new password and yescrypt settings.
    • Output output: yescrypt string with new salt and password hash

You can also use the raw YescryptKdf class if you want complete control of the KDF.

Limitations

This implementation does not support p>1 (no parallelism ). It does not support ROMs either. Therefore, it is best suited casual checking of passwords and password hash maintenance. It is (obviously) not suitable for proof of work or similar use cases where large numbers of hashes need be calculated with maximum efficiency.

This implementation has been tested with YESCRYPT_RW flavor. This is the flavor you should use anyway. If this code encounters YESCRYPT_WORM hashes... things might break.

Credits

This is a straight port of the "ref" implementation from the original Openwall C sources. I left in comments so that it is easy to compare the c# port with the original C soruces.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.15 166 4/12/2024
1.0.13 6,675 11/10/2023
1.0.12 94 11/10/2023
1.0.11 11,373 2/4/2023
1.0.10 264 2/4/2023
1.0.0-dev-8 141 2/4/2023
1.0.0-dev-7 134 2/4/2023
1.0.0-dev-5 137 2/4/2023
1.0.0-dev-4 131 2/3/2023

- Initial version validated against latest Ubuntu / Debian release
- Limitations:
   1. Does not implement p>1 (i.e., no parallelism)
   2. No ROMs support, and therefore, is best suited to casual checking of passwords, not proof of work or password cracking
   3. Only tested with YESCRYPT_RW flavor, if YESCRYPT_WORM flavor is encountered, an exception will be thrown
- Added support for arbitrary salt length