Mono Class Library: System.Security.Cryptography.PasswordDeriveBytes Overview | Members

System.Security.Cryptography.PasswordDeriveBytes.GetBytes Method

Request a buffer of derived bytes from the algorithm. [Edit]

[System.Obsolete("see Rfc2898DeriveBytes for PKCS#5 v2 support")]
public override byte[] GetBytes (int cb)

Parameters

cb
The length of derived bytes requested. [Edit]

Returns

An array of the specified length contaning bytes derived of the secret password and other (possibly public) informations. [Edit]

Remarks

SECURITY WARNING: You should never ask for more bytes than the PasswordDeriveBytes.HashName digest algorithm can provide (e.g. 20 bytes maximum for SHA-1). This is the maximum you can get securely (i.e. don't try to get a 256 bits key using SHA-1). The PKCS#5 specification dictates to return an error if more is asked, however MS implementation does support it.

INTEROPERABILITY WARNING: The previous undocumented behaviour isn't 100% compatible between Mono and MS implementation and should be avoided when possible. If it cannot be avoided try to call GetBytes once then split the bytes amongst multiple variables (e.g. key, iv) if required. This seems to be the safest way to interoperate between the two implementations.

[Edit]

Requirements

Namespace: System.Security.Cryptography
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0