Skip to content

libsodium.Password.GenerateHash

Andrew Lambert edited this page Nov 26, 2022 · 8 revisions

libsodium.Password.GenerateHash

Method Signature

 Function GenerateHash(HashAlgorithm As Int32 = libsodium.Password.ALG_ARGON2, Limits As libsodium.ResourceLimits = libsodium.ResourceLimits.Interactive) As MemoryBlock

Parameters

Name Type Comment
HashAlgorithm Int32 Optional. Either ALG_ARGON2 (default) or ALG_SCRYPT.
Limits ResourceLimits Optional. A member of the ResourceLimits enumeration.

Return value

A fixed-length hash of the password.

Remarks

This method computes a computationally-intensive salted hash (either Argon2i or scrypt) of the password. The resulting hash value is suitable for storage (e.g. in a database).

The salt is selected at random and is included as part of the output. Use the VerifyHash method to validate a password.

You can fine-tune how resource-intensive the hash operation is by changing the Limits parameter. The default is Interactive, which is the least intensive (i.e. suitable for interactive desktop programs.) Beware that this method may fail if the Limits are so intensive that the system can't or won't satisfy them.

Clone this wiki locally