The ReadFile method can be used to encrypt, decrypt, hash , sign or verify data from a file to memory.
Parameter | Description |
---|---|
sSourceFilename | The path and filename of the file to read and process data from. |
lSourceOffset | The starting offset in the file to begin processing data from. Specify 0 to begin processing data from the beginning of the file. |
lSourceSize | The amount of data to process. Specify 0 to process data from the starting offset until the end of the file. |
eAction | The type of processing that should be performed. When using the ReadFile method in the Xceed Encryption control, you can specify efpEncrypt or efpDecrypt to encrypt or decrypt data before writing it to memory. When using the ReadFile method in the Xceed Hashing control, specify efpHash to hash data and write the resulting hash value to the HashValue property. When using the ReadFile method in the Xceed Signing control, specify efpSign to digitally sign the data and write the digital signature to the Signature property. Specify efpVerify to verify data against a digital signature, making sure to place the digital signature beforehand in the Signature property. |
bEndOfData | Determines whether or not the source data to read is the final (or the only) portion of data to process. Specify True if the source data should be completely encrypted, decrypted, hashed, signed or verified and written to memory. If the data to process is split apart in various sections of the same file, or in various files, then you can specify False in this parameter until all the source data has been read. You can specify True for the last portion of data (which can be 0 bytes long) so that the library knows it must finish processing the source data and return the last of the processed data immediately. When specifying False, the library will expect you to call the ReadFile method again later with either a new source filename and/or source offset and/or source size. |
vaBytesRead | You must provide a variant variable in this parameter. Right before the ReadFile method completes and returns, the library will write to the variable the amount of bytes read and processed from the source file. |
When encrypting or decrypting data, this method returns a byte array variant containing the encrypted or decrypted data.
Also when encrypting or decrypting data, calling the ReadFile method with the bEndOfData parameter specified as False, the returned byte array variant may not contain any data. This can happen whenever the encoder or the decoder has not received enough source data in order to output a processed block.
When hashing or signing data, this method does not return anything. The resulting hash value or digital signature are placed in the HashValue or Signature properties. When verifying data and the data matches the digital signature, this method will complete without error. If the verified data does not correspond to the digital signature, this method will return eerVerifyFailed error.
ToString and FromString
When calling the ReadFile method with the bEndOfData parameter specified as False, you cannot call any other Xceed Encryption control method (of the same instance of the control) until you have completed processing a stream of data by calling the ReadFile method with the bEndOfData parameter specified as True, or an error occurs, or the Reset method is called.
When encrypting with a secret-key encryption algorithm, the library may automatically pad the last encrypted block with a fixed value (the value used corresponds to the number of bytes padded). The PaddingMethod property determines exactly how padding will be performed. When decrypting, the library will make sure that these padding characters are recognized and ignored. This padding scheme implies that there may be an additional block at the end of the encrypted data stream containing bytes of all the same plain text value (usually 16).
With Visual Basic, it is often necessary to convert the resulting processed data from a byte array variant to a native VB byte array before saving it or transmitting it. VB6 makes it particularly easy to do the conversion: If you have a variant named (for example) ProcessedData, you can convert it to a native VB byte array with the following code:
Visual Basic | ![]() |
---|---|
|
With Microsoft Access, you can place the processed data in either a Memo field or an OLE Object field. Using an OLE Object field in a table is the easiest: You can directly assign your data to the field and conversion is automatic. To assign the processed data variant to a Memo field, use the "AppendChunk" function in Access.
Declaration (DXceedEncryption) | ![]() |
---|---|
HRESULT ReadFile |
Declaration (IXceedEncryption) | ![]() |
---|---|
|