Click or drag to resize

PbeScrypt(Int32, Byte, Byte, Int32, Int32, Int32) Method

Derives a key of any length from a password using the SCRYPT algorithm.

Namespace: CryptoSysPKI
Assembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.25611 (23.0.0.0)
Syntax
public static byte[] Scrypt(
	int dkLen,
	byte[] pwdBytes,
	byte[] salt,
	int N,
	int r,
	int p
)

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

Byte
Key in byte[] format
Example
C#
// Test vectors from [RFC7914]
// scrypt (P="password", S="NaCl", N=1024, r=8, p=16, dkLen=64)
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());
// FDBABE1C9D3472007856E7190D01E9FE7C6AD7CBC8237830E77376634B373162
// 2EAF30D92E22A3886FF109279D9830DAC727AFB94A83EE6D8360CBDFA2CC0640
See Also