Gemstone Security Library
Show/Hide TOC

# Argon2Hash(String, String, Int32, Int32, Int32, Argon2Type, Int32) Method

Hash the given password to an Argon2 hash string.

## Definition

Namespace: Gemstone.Security.Cryptography.Argon2Hash
Assembly: Gemstone.Security (in Gemstone.Security.dll) Version: 1.0.164 -- Release Build+02f5beeaeb38c331bcb40c1e81a5f010ffc838b5
C#
View Source Request Example

    public static string Hash(
    	string password,
    	string? secret,
    	int timeCost = 3,
    	int memoryCost = 65536,
    	int parallelism = 1,
    	Argon2Type type = Argon2Type.HybridAddressing,
    	int hashLength = 32
    )

VB
View Source Request Example

    Public Shared Function Hash (
    	password As String,
    	secret As String,
    	Optional timeCost As Integer = 3,
    	Optional memoryCost As Integer = 65536,
    	Optional parallelism As Integer = 1,
    	Optional type As Argon2Type = Argon2Type.HybridAddressing,
    	Optional hashLength As Integer = 32
    ) As String

C++
View Source Request Example

    public:
    static String^ Hash(
    	String^ password,
    	String^ secret,
    	int timeCost = 3,
    	int memoryCost = 65536,
    	int parallelism = 1,
    	Argon2Type type = Argon2Type::HybridAddressing,
    	int hashLength = 32
    )

JavaScript
View Source Request Example

    Gemstone.Security.Cryptography.Argon2Hash.Argon2.Hash = function(password, secret, timeCost, memoryCost, parallelism, type, hashLength);

#### Parameters

password String
  The password to hash. Gets UTF-8 encoded before hashing.
secret String
  The secret to use in creating the hash. UTF-8 encoded before hashing. May be null. A string.Empty is treated the same as null.
timeCost Int32 (Optional)
  The time cost to use. Defaults to 3.
memoryCost Int32 (Optional)
  The target memory cost to use. Defaults to 65536 (65536 * 1024 = 64MB). MemoryCost for detail on calculating the actual memory used from this value.
parallelism Int32 (Optional)
  The parallelism to use. Default to 1 (single threaded).
type Argon2Type (Optional)
  Data-dependent, data-independent, or hybrid. Defaults to hybrid (as recommended for password hashing).
hashLength Int32 (Optional)
  The length of the hash in bytes. Note, the string returned base-64 encodes this with other parameters so the resulting string is significantly longer.

#### Return Value

String
The Argon2 hash of the given password.

## See Also

#### Reference

Argon2 Class
Hash Overload
Gemstone.Security.Cryptography.Argon2Hash Namespace