PbeScrypt(Int32, Byte, Byte, Int32, Int32, Int32) Method |
Derives a key of any length from a password using the SCRYPT algorithm.
Namespace: CryptoSysPKIAssembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.25611 (23.0.0.0)
Syntaxpublic static byte[] Scrypt(
int dkLen,
byte[] pwdBytes,
byte[] salt,
int N,
int r,
int p
)
Public Shared Function Scrypt (
dkLen As Integer,
pwdBytes As Byte(),
salt As Byte(),
N As Integer,
r As Integer,
p As Integer
) As Byte()
Parameters
- dkLen Int32
- Required length of key in bytes
- pwdBytes Byte
- Password encoded in byte format
- salt Byte
- Salt in byte format
- N Int32
- CPU/Memory cost parameter, a number greater than one and a power of 2.
- r Int32
- Block size r
- p Int32
- Parallelization parameter p
Return Value
ByteKey in byte[] format
Example
int dkLen = 64;
byte[] pwd = System.Text.Encoding.Default.GetBytes("password");
byte[] salt = System.Text.Encoding.Default.GetBytes("NaCl");
byte[] key = Pbe.Scrypt(dkLen, pwd, salt, 1024, 8, 16);
Debug.Assert(key.Length > 0, "ERROR with Pbe.Scrypt");
Console.WriteLine("dk={0}", key.ToHex());
See Also