VB example VB streaming example
Delphi example Delphi streaming example
VC++ example VC++ streaming example
How to obtain the digital signature of a file in a single pass
How to obtain the digital signature of a file in a streaming fashion
To create a digital signature of a file in a single pass, perform the following 5 steps. Put the Xceed Signing control on a form or instantiate it, then:
Specify the signing method to use. To do this, create an instance of the XceedRSASigningMethod object and assign it to the SigningMethod property.
Specify the Private Key to use. To do this, set the XceedRSASigningMethod object's PrivateKey property. If you don't have a Private Key , you can generate a PrivateKey -PublicKey pair by calling the SetRandomKeyPair method, which will place a Private Key in the PrivateKey property, and the corresponding Public Key in the PublicKey property.
Tell the library to read the file and create the signature. To do this, call the ReadFile method, passing the filename of the file to digitally sign, the efpSign action, and True for the bEndOfData parameter.
Obtain the digital signature. To do this, read the contents of the Signature property.
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 create a digital signature of a file by reading the data in multiple passes, perform the following 7 steps. Put the Xceed Signing control on a form or instantiate it, then:
Specify the signing method to use. To do this, create an instance of the XceedRSASigningMethod object and assign it to the SigningMethod property.
Specify the Private Key to use. To do this, set the XceedRSASigningMethod object's PrivateKey property. If you don't have a Private Key , you can generate a PrivateKey -PublicKey pair by calling the SetRandomKeyPair method, which will place a Private Key in the PrivateKey property, and the corresponding Public Key in the PublicKey property.
Tell the library to read some data from the file. To do this, call the ReadFile method, passing the filename of the file to digitally sign, the efpSign action, and 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 read during the first pass. You can use for example 32768 bytes per portion.
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 read data from the file until 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 an empty filename. In this case processing is complete.
Obtain the digital signature. To do this, read the contents of the Signature property.
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.