PbeKdf2(Int32, String, String, Int32, HashAlgorithm) Method |
Derive a key in hex format of any length from a password with the salt in hex format.
Namespace: CryptoSysPKIAssembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.25611 (23.0.0.0)
Syntaxpublic static string Kdf2(
int dkLen,
string pwdStr,
string saltHex,
int count,
HashAlgorithm hashAlg = HashAlgorithm.Sha1
)
Public Shared Function Kdf2 (
dkLen As Integer,
pwdStr As String,
saltHex As String,
count As Integer,
Optional hashAlg As HashAlgorithm = HashAlgorithm.Sha1
) As String
Parameters
- dkLen Int32
- Required length of key in bytes
- pwdStr String
- Password
- saltHex String
- Salt in hex format
- count Int32
- Iteration count
- hashAlg HashAlgorithm (Optional)
- Hash algorithm to use in HMAC PRF (default is SHA-1)
Return Value
StringKey in hex format
Examplestring saltHex = "78578e5a5d63cb06";
int n = 24;
string keyStr = Pbe.Kdf2(n, "password", saltHex, 2048, HashAlgorithm.Sha256);
Debug.Assert(keyStr.Length > 0, "ERROR with PbeKdf2/Hex");
Console.WriteLine("Key({0})={1}", n * 8, keyStr);
See Also