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