Class EncodeExtension
Extension to encode an Argon2 hash string.
Inherited Members
Namespace: Isopoh.Cryptography.Argon2
Assembly: Isopoh.Cryptography.Argon2.dll
Syntax
public static class EncodeExtension
Methods
| Edit this page View SourceEncodeString(Argon2Config, Span<byte>)
Encodes an Argon2 instance into a string.
Declaration
public static string EncodeString(this Argon2Config config, Span<byte> hash)
Parameters
| Type | Name | Description |
|---|---|---|
| Argon2Config | config | To encode. |
| Span<byte> | hash | The hash to put in the encoded string. May be null. |
Returns
| Type | Description |
|---|---|
| string | The encoded Argon2 instance. |
Remarks
Resulting format:
$argon2<T>[$v=<num>]$m=<num>,t=<num>,p=<num>[,keyid=<bin>][,data=<bin>][$<bin>[$<bin>]].
where <T> is either 'd' or 'i', <num> is a decimal integer (positive, fits in an 'unsigned long'), and <bin> is Base64-encoded data (no '=' padding characters, no newline or whitespace). The "keyid" is a binary identifier for a key (up to 8 bytes); "data" is associated data (up to 32 bytes). When the 'keyid' (resp. the 'data') is empty, then it is omitted from the output.
The last two binary chunks (encoded in Base64) are, in that order, the salt and the output. Both are optional, but you cannot have an output without a salt. The binary salt length is between 8 and 48 bytes. The output length is always exactly 32 bytes.
EncodeString(Argon2Memory, Span<byte>)
Encodes an Argon2 instance into a string.
Declaration
public static string EncodeString(this Argon2Memory memory, Span<byte> hash)
Parameters
| Type | Name | Description |
|---|---|---|
| Argon2Memory | memory | To encode. |
| Span<byte> | hash | The hash to put in the encoded string. May be null. |
Returns
| Type | Description |
|---|---|
| string | The encoded Argon2 instance. |
Remarks
Resulting format:
$argon2<T>[$v=<num>]$m=<num>,t=<num>,p=<num>[,keyid=<bin>][,data=<bin>][$<bin>[$<bin>]].
where <T> is either 'd' 'i', or 'id', <num> is a decimal integer (positive, fits in an 'unsigned long'), and <bin> is Base64-encoded data (no '=' padding characters, no newline or whitespace). The "keyid" is a binary identifier for a key (up to 8 bytes); "data" is associated data (up to 32 bytes). When the 'keyid' (resp. the 'data') is empty, then it is omitted from the output.
The last two binary chunks (encoded in Base64) are, in that order, the salt and the output. Both are optional, but you cannot have an output without a salt. The binary salt length is between 8 and 48 bytes. The output length is always exactly 32 bytes.
EncodeString(Argon2Type, Argon2Version, int, int, int, Span<byte>, Span<byte>, Span<byte>, Span<byte>)
Encodes an Argon2 instance into a string.
Declaration
public static string EncodeString(Argon2Type type, Argon2Version version, int memoryCost, int timeCost, int lanes, Span<byte> keyId, Span<byte> associatedData, Span<byte> salt, Span<byte> hash)
Parameters
| Type | Name | Description |
|---|---|---|
| Argon2Type | type | Type to put in the encoded string. |
| Argon2Version | version | Version to put in the encoded string. |
| int | memoryCost | Memory cost to put in the encoded string. |
| int | timeCost | Time cost to put in the encoded string. |
| int | lanes | Lanes to put in the encoded string. |
| Span<byte> | keyId | The key identifier to place in the hash string. May be empty. |
| Span<byte> | associatedData | The associated data to place in the hash string. May be empty. |
| Span<byte> | salt | The salt to put in the encoded string. May be empty. |
| Span<byte> | hash | The hash to put in the encoded string. May be empty. |
Returns
| Type | Description |
|---|---|
| string | The encoded Argon2 instance. |
Remarks
Resulting format:
$argon2<T>[$v=<num>]$m=<num>,t=<num>,p=<num>[,keyid=<bin>][,data=<bin>][$<bin>[$<bin>]].
where <T> is either 'd' 'i', or 'id', <num> is a decimal integer (positive, fits in an 'unsigned long'), and <bin> is Base64-encoded data (no '=' padding characters, no newline or whitespace). The "keyid" is a binary identifier for a key (up to 8 bytes); "data" is associated data (up to 32 bytes). When the 'keyid' (resp. the 'data') is empty, then it is omitted from the output.
The last two binary chunks (encoded in Base64) are, in that order, the salt and the output. Both are optional, but you cannot have an output without a salt. The binary salt length is between 8 and 48 bytes. The output length is always exactly 32 bytes.
ToB64String(Span<byte>)
Make an Argon2 B64 string which is an RFC 4648 Base64 string without the trailing '=' padding.
Declaration
public static string ToB64String(this Span<byte> buf)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<byte> | buf | The buffer to convert to a string. |
Returns
| Type | Description |
|---|---|
| string | The Argon2 B64 string. |