VB example VB streaming example
Delphi example Delphi streaming example
VC++ example VC++ streaming example
You can freely replace the word "encrypt" with "decrypt" to find out how to decrypt data because encrypting and decrypting work exactly the same way.
To encrypt data with Rijndael or Twofish from file to memory in a single pass, perform the following 5 steps. Put the Xceed Encryption control on a form or instantiate it, then:
Specify the encryption method to use. To do this, create an instance of the XceedRijndaelEncryptionMethod object or the XceedTwofishEncryptionMethod object and assign it to the EncryptionMethod property.
Specify the Secret Key to use. To do this from a PassPhrase , use the SetSecretKeyFromPassPhrase method that belongs to the Encryption Method object you assigned to the EncryptionMethod property.
Tell the library to encrypt. To do this, call the ReadFile method, passing the source filename and specifying True for the bEndOfData parameter.
Obtain the encrypted data. To do this, assign the return value of the ReadFile method to the variable of your choice.
Make sure that everything worked properly. To do this, use your language's error handling object or error handling capabilities. The Xceed Encryption Library supports standard COM error handling functionality.
To encrypt data with RSA from file to memory in a single pass, perform the following 5 steps. Put the Xceed Encryption control on a form or instantiate it, then:
Specify the encryption method to use. To do this, create an instance of the XceedRSAEncryptionMethod object and assign it to the EncryptionMethod property.
If you are encrypting, specify the Public Key to use. To do this, set the PublicKey property that belongs to the XceedRSAEncryptionMethod object you assigned to the EncryptionMethod property. If you are decrypting, specify the Private Key to use. To do this, set the PrivateKey property instead. If you need to create an RSA-compatible Public Key and Private Key pair to use, then call the SetRandomKeyPair method and retrieve the keys from the PublicKey and PrivateKey properties.
Tell the library to encrypt. To do this, call the ReadFile method, passing the source filename and specifying True for the bEndOfData parameter.
Obtain the encrypted data. To do this, assign the return value of the ReadFile method to the variable of your choice.
Make sure that everything worked properly. To do this, use your language's error handling object or error handling capabilities. The Xceed Encryption Library supports standard COM error handling functionality.
To encrypt data using Rijndael or Twofish from file to memory, while processing the source file's data in smaller portions, perform the following 6 steps. Put the Xceed Encryption Control on a form or instantiate it, then:
Specify the encryption method to use. To do this, create an instance of the XceedRijndaelEncryptionMethod object or the XceedTwofishEncryptionMethod object and assign it to the EncryptionMethod property.
Determine the size of the file you will compress.
Specify the Secret Key to use. To do this from a PassPhrase , use the SetSecretKeyFromPassPhrase method that belongs to the Encryption Method object you assigned to the EncryptionMethod property.
Tell the library to encrypt some data from the file. To do this, call the ReadFile method for each portion of data, passing the source filename and specifying False for the bEndOfData parameter. Provide a starting offset of 0, and the size you specify should be the amount of data you want the library to encrypt during the first pass. You can use for example 32768 bytes per portion.
Accumulate the encrypted data. To do this, append the data returned by the ReadFile method to a variable which contains the complete encrypted memory buffer so far. You can also process the encrypted data as it is returned by the library or pass it to other streaming methods.
Increment your current offset. The ReadFile method returns the amount of bytes read via the lBytesRead parameter. Add this amount to your offset.
Continue telling the library to encrypt data from the file until the your offset reaches the file's size. If your offset is smaller than the file size, call the ReadFile method, setting bEndOfData to False and passing the same filename, your new offset, and your portion size. If your offset has reached the file's size, call the ReadFile method with bEndOfData set to False, 0 for offset, 0 for file size, and if you want, an empty filename. In this case processing is complete.
Make sure that everything worked properly. To do this, use your language's error handling object or error handling capabilities. The Xceed Encryption Library supports standard COM error handling functionality.