Exemplo n.º 1
0
    VerifyHash2id(byte[] password, byte[] hashCanditate, Argon2Parameter param)
    {
        if (password == null || hashCanditate == null)
        {
            return(false);
        }

        byte[] _hash = ComputeHash2id(password, param);

        if (_hash == null)
        {
            return(false);
        }

        return(_hash.SequenceEqual(hashCanditate));
    }
Exemplo n.º 2
0
    ComputeHash2id(byte[] password, Argon2Parameter param)
    {
        var a2id = new Argon2id(password);

        try
        {
            a2id.DegreeOfParallelism = param.Parallelism;
            a2id.MemorySize          = param.MemorySize1Kb;
            a2id.Iterations          = param.Iterations;
            a2id.AssociatedData      = param.Data;

            a2id.Salt = param.Salt;

            return(a2id.GetBytes(param.ByteCount));
        }
        catch (Exception)
        {
            return(null);
        }
        finally
        {
            a2id.Dispose();
        }
    }