CryptoSys PKI Pro Manual

Pbe.Scrypt(Int32, Byte[], Byte[], Int32, Int32, Int32) Method

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

Syntax

[C#]
public static byte[] Scrypt(
   int dkLen,
   byte[] pwdBytes,
   byte[] salt,
   int N,
   int r,
   int p 
)
[VB]
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

Byte
Key in byte[] format

Example

// 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

VB6/C equivalent: PBE_Scrypt

[Contents] [Index]

[PREV: Pbe.Kdf2(Int32, String, String, Int32, HashAlgorithm) Method...]   [Contents]   [Index]   
   [NEXT: Pbe.Scrypt(Int32, String, String, Int32, Int32, Int32) Method...]

Copyright © 2004-26 D.I. Management Services Pty Ltd t/a CryptoSys. All rights reserved. Generated 2026-09-21T05:59:39Z.