Connectivity Software User's Guide and Reference
HashPassword Method



OpcLabs.BaseLib Assembly > OpcLabs.BaseLib.Security.User Namespace > MemoryNameAndPasswordUserManager Class : HashPassword Method
The password to hash.

The value of this parameter cannot be null (Nothing in Visual Basic).

The algorithm ID to use for hashing.

The value of this parameter cannot be null (Nothing in Visual Basic).

The number of iterations for hashing.
The salt to use in hashing.

The value of this parameter cannot be null (Nothing in Visual Basic).

Hashes a password using the specified algorithm, iterations, and salt.
Syntax
'Declaration
 
<JetBrains.Annotations.NotNullAttribute()>
Protected Overridable Function HashPassword( _
   ByVal password As String, _
   ByVal algorithmId As String, _
   ByVal iterations As Nullable(Of Integer), _
   ByVal salt() As Byte _
) As Byte()
'Usage
 
Dim instance As MemoryNameAndPasswordUserManager
Dim password As String
Dim algorithmId As String
Dim iterations As Nullable(Of Integer)
Dim salt() As Byte
Dim value() As Byte
 
value = instance.HashPassword(password, algorithmId, iterations, salt)
[JetBrains.Annotations.NotNull()]
protected virtual byte[] HashPassword( 
   string password,
   string algorithmId,
   Nullable<int> iterations,
   byte[] salt
)
[JetBrains.Annotations.NotNull()]
protected:
virtual array<byte>^ HashPassword( 
   String^ password,
   String^ algorithmId,
   Nullable<int> iterations,
   array<byte>^ salt
) 

Parameters

password
The password to hash.

The value of this parameter cannot be null (Nothing in Visual Basic).

algorithmId
The algorithm ID to use for hashing.

The value of this parameter cannot be null (Nothing in Visual Basic).

iterations
The number of iterations for hashing.
salt
The salt to use in hashing.

The value of this parameter cannot be null (Nothing in Visual Basic).

Return Value

A byte array containing the hashed password.

This method never returns null (Nothing in Visual Basic).

Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

An invoked method is not supported at all, or is not supported with the parameters used to create the object.
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also