#if !STELLAOPS_CRYPTO_SODIUM
using System;
using System.Text;
using Konscious.Security.Cryptography;

namespace StellaOps.Cryptography;

/// <summary>
/// Managed Argon2id implementation powered by Konscious.Security.Cryptography.
/// </summary>
public sealed partial class Argon2idPasswordHasher
{
    private static partial byte[] DeriveHashCore(string password, ReadOnlySpan<byte> salt, PasswordHashOptions options)
    {
        var passwordBytes = Encoding.UTF8.GetBytes(password);

        using var argon2 = new Argon2id(passwordBytes)
        {
            Salt = salt.ToArray(),
            DegreeOfParallelism = options.Parallelism,
            Iterations = options.Iterations,
            MemorySize = options.MemorySizeInKib
        };

        return argon2.GetBytes(HashLengthBytes);
    }
}
#endif
