DecryptData Method  
 

Decrypt the contents of the specified string or byte array.

Syntax

object.DecryptData( InputData, OutputData [, Password ])

Parameters

InputData
A string or byte array that contains the data to be decrypted.
OutputData
A string or byte array which will contain the decrypted data when the method returns. This parameter must be passed by reference. When specifying a Byte array, you must ensure the buffer is large enough to contain all of the decrypted data.
Password
An optional parameter that specifies the password that was used to decrypt the data. If this parameter is omitted, the value of the Password property will be used.

Return Value

This method returns the number of bytes of decrypted data copied into the output buffer. If the input buffer is a zero-length string or an empty array, the method will return zero. If an error occurs, the method will return -1. Check the value of the LastError property to determine the specific error that has occurred.

Remarks

The DecryptData method will decrypt the contents of the input buffer previously encrypted with the EncryptData method. Thee decrypted data is returned in the specified output buffer. The password (or passphrase) provided by the caller is used to generate a SHA-256 hash value which is used as part of the decryption process.

Important

The input and output buffer variables must match the same data types which were used when calling the EncryptData method. If it was used to encrypt a string, then the input and output variables must be String types. If it was used to encrypt binary data, the input and output variables must be Byte arrays. Never attempt to encrypt or decrypt binary data using String variables. You must always use a Byte array for binary data.

Due to how the SHA-256 hash is generated, this method cannot be used to decrypt files that were encrypted using another third-party library. It can only be used to decrypt data that was previously encrypted using EncryptData.

If you wish to encrypt and decrypt the contents of a file, use the EncryptFile and DecryptFile methods.

This method uses the Microsoft CryptoAPI and the RSA AES cryptographic provider. This provider may not be available in some languages, countries or regions. The availability of this provider may also be constrained by cryptography export restrictions imposed by the United States or other countries. If the required cryptographic provider is not available, the method will fail.

See Also

CompressFile Method, EncryptData Method, ExpandData Method, ExpandFile Method