Argon2.VerifyPassword Method
Namespace: Rebex.Security.Cryptography
Assembly: Rebex.Security.dll (version 7.0.9313)
VerifyPassword(String, ArraySegment<Byte>)
Verifies that the encodedPasswordHash matches the hash of the password.
The format of the encoded hash is described in the remarks section of Argon2 class documentation.
Declaration
public static bool VerifyPassword(string encodedPasswordHash, ArraySegment<byte> password)Parameters
| Type | Name | Description | 
|---|---|---|
| String | encodedPasswordHash | The string that contains an encoded password hash. | 
| ArraySegment<Byte> | password | The ArraySegment<T> that contains a password to hash and compare with  | 
Returns
| Type | Description | 
|---|---|
| Boolean | True if the  | 
Remarks
Encoded hash can be created using a HashPassword method.
Examples
// encodedPasswordHash has been previously created using the HashPassword method.
// Encoded password hash has the following structure:
// $argon2id$v=19$m=65536,t=10,p=4$MTIzNDU2Nzg$GVfTf0x89BTwcW7HhQMYRcgPwOzswaw6UUBWDBXP0kc
public bool CanAuthenticateUser(string encodedPasswordHash, string userPasswordFromUi)
{
    // Convert password to a byte array segment.
    var passwordBytes = new ArraySegment<byte>(Encoding.UTF8.GetBytes(userPasswordFromUi));
    // Returns true when encodePasswordHash matches the hash of userPasswordFromUi;
    // otherwise returns false.
    return Argon2.VerifyPassword(encodedPasswordHash, passwordBytes);
}Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | The  | 
See Also
VerifyPassword(String, String)
Verifies that the encodedPasswordHash matches the hash of the password.
The format of the encoded hash is described in the remarks section of Argon2 class documentation.
Declaration
public static bool VerifyPassword(string encodedPasswordHash, string password)Parameters
| Type | Name | Description | 
|---|---|---|
| String | encodedPasswordHash | The string that contains an encoded password hash. | 
| String | password | The String that contains a password to hash compare with  | 
Returns
| Type | Description | 
|---|---|
| Boolean | True if the  | 
Remarks
Encoded hash can be created using a HashPassword method.
Examples
// encodedPasswordHash has been previously created using the HashPassword method.
// Encoded hash has the following structure:
// $argon2id$v=19$m=65536,t=10,p=4$MTIzNDU2Nzg$GVfTf0x89BTwcW7HhQMYRcgPwOzswaw6UUBWDBXP0kc
public bool CanAuthenticateUser(string encodedPasswordHash, string userPasswordFromUi)
{
    // Returns true when encodePasswordHash matches the hash of userPasswordFromUi;
    // otherwise returns false.
    return Argon2.VerifyPassword(encodedPasswordHash, userPasswordFromUi);
}Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | The  | 
See Also
VerifyPassword(String, Byte[])
Verifies that the encodedPasswordHash matches the hash of the password.
The format of the encoded hash is described in the remarks section of Argon2 class documentation.
Declaration
public static bool VerifyPassword(string encodedPasswordHash, byte[] password)Parameters
| Type | Name | Description | 
|---|---|---|
| String | encodedPasswordHash | The string that contains an encoded password hash. | 
| Byte[] | password | The byte array that contains a password to hash and compare with  | 
Returns
| Type | Description | 
|---|---|
| Boolean | True if the  | 
Remarks
Encoded hash can be created using a HashPassword method.
Examples
// encodedPasswordHash has been previously created using the HashPassword method.
// Encoded hash has the following structure:
// $argon2id$v=19$m=65536,t=10,p=4$MTIzNDU2Nzg$GVfTf0x89BTwcW7HhQMYRcgPwOzswaw6UUBWDBXP0kc
public bool CanAuthenticateUser(string encodedPasswordHash, byte[] userPasswordFromUi)
{
    // Returns true when encodePasswordHash matches the hash of userPasswordFromUi;
    // otherwise returns false.
    return Argon2.VerifyPassword(encodedPasswordHash, userPasswordFromUi);
}Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | The  |