VB example VB streaming example
Delphi example Delphi streaming example
VC++ example VC++ streaming example
How to hash a file's data in a single pass
How to hash a file's data in multiple passes
To create a hash value of a file in a single pass, perform the following steps. Put the Xceed Hashing control on a form or instantiate it, then:
Specify the hashing method to use. To do this, create an instance of the XceedSHAHashingMethod or XceedHavalHashingMethod object and assign it to the HashingMethod property.
Specify the size (in bits) of the desired hash value. To do this, set the HashSize property.
Tell the library to read the file and create the hash value. To do this, call the ReadFile method, passing the filename of the file to digitally sign, the efpHash action, and True for the bEndOfData parameter.
Obtain the hash value. To do this, read the contents of the HashValue 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 obtain the hash value for a file in multiple passes, perform the following steps. Put the Xceed Hashing control on a form or instantiate it, then:
Specify the hashing method to use. To do this, create an instance of the XceedSHAHashingMethod or XceedHavalHashingMethod object and assign it to the HashingMethod property.
Specify the size (in bits) of the desired hash value. To do this, set the HashSize 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 hash, the efpHash 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 hash value. To do this, read the contents of the HashValue 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.