Windows apps
Collapse the table of content
Expand the table of content

ProtectedData.Protect Method (Byte[], Byte[])

.NET Framework (current version)

Encrypts the data in a specified byte array and returns a byte array that contains the encrypted data.

Namespace:  System.Security.Cryptography
Assembly:  mscorlib.Extensions (in mscorlib.Extensions.dll)

public static byte[] Protect(
	byte[] userData,
	byte[] optionalEntropy
)

Parameters

userData
Type: System.Byte[]

The data to encrypt.

optionalEntropy
Type: System.Byte[]

Optional data used to increase the complexity of the encryption, or null for no additional complexity.

Return Value

Type: System.Byte[]
A byte array representing the encrypted data.

ExceptionCondition
ArgumentNullException

The userData parameter is null.

CryptographicException

The encryption failed.

NotSupportedException

The operating system does not support this method.

OutOfMemoryException

The system ran out of memory while encrypting the data.

Supported in: Windows Phone Silverlight 8
Show:
© 2017 Microsoft