Encrypts the contents of a file using AES-256 encryption.
A boolean value which specifies if the method was successful or not. A return value of true indicates that the method call completed successfully. A return value of false indicates that the method failed and the application should check the value of the LastError property.
This method will encrypt the contents of a file using a 256-bit AES (Advanced Encryption Standard) algorithm and stores the encrypted data in the specified output file. The value of the Password property is used to generate the encryption key.
It is recommended that most applications specify as password value. If the value of the Password property is an empty string, a default internal hash value will be used to create the encryption key. This means that any other SocketTools application which uses this method will be able to decrypt the data.
Due to how the SHA-256 hash is generated, the encrypted data cannot be decrypted using another third-party library with the same password value. It can only be decrypted using the DecryptFile method.
A temporary file is created during the encryption process and the output file is created or overwritten only if the input file could be successfully encrypted. If the encryption fails, no output file will be created.
The input file contents will always be processed as a binary data stream. If you use this method to encrypt a text file, the output file will contain binary characters, not printable text. If you wish to transfer or store the encrypted data as text, it should be encoded using the EncodeFile method after calling this method.
If your application is also using the CompressFile method to compress the data, it is recommended that you call CompressFile before calling EncryptFile. You will typically achieve a better compression rate on unencrypted data than attempting to compress data which has been encrypted with this method.
If you wish to encrypt the contents of a memory buffer or string, use the EncryptData 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.