HashCryptStreams SFStreamDigest object
 

1. Creation and ProgID
2. Overview
3. Members reference
See also: Stream filter concepts 

Creation and ID-s

Threading model: Both
Program ID: newObjects.crypt.SFStreamDigest
ClassID: {61589F56-3682-4912-9AF9-34BA97551D53}
Threading model: Free
ProgramID: newObjects.crypt.SFStreamDigest.free
ClassID: {ED35381F-49AA-49f1-AD4E-FCD2C8180236}

Overview

This object implements a stream filter that can Hash/HMAC data while it is read/written through it. This object is feasible when the application uses various streams extensively and if it will be beneficial to leave some parts of the application unaware of the Hash/HMAC generation. If that is not the case the excess code needed to initialize and manage the object will not be justified. 

It is recommended to read the Stream filters concepts first. 

Reference

method.gif (107 bytes) ReadReset
WriteReset
Syntax:
object.ReadReset
object.WriteReset

Resets the Write or the Read processor of the object respectively. Leaves the selected algorithm and Key (if any) intact.

WriteHashEnable
ReadHashEnable
Syntax:
object.WriteHashEnable = b
b = object.WriteHashEnable
object.ReadHashEnable = b
b = object.ReadHashEnable

Boolean. Enables the Read or the Write processor of the object respectively. Using this property you can disable/enable the data processing as needed. For example you may want to transfer some data through the stream filter without generating a digest over it. By default the both processors are disabled!

method.gif (107 bytes) WriteResetKey
ReadResetKey
Syntax:
object.WriteResetKey
object.ReadResetKey

Resets the Write or the Read processor of the object respectively. Leaves the selected algorithm intact, but clears the Key.

method.gif (107 bytes) WriteFinalize
ReadFinalize
Syntax:
object.WriteFinalize
object.ReadFinalize

Finalizes the digest for the Read or the Write processor respectively. The processing occurs like this:
The SFStreamDigest stream filter is attached to another stream and the stream filter is driven through a SFStream object. When the application completes with the transfer of a data over which a hash needs to be generated it calls WriteFinalize or ReadFinalize (depending on the direction in which the data is transfered) and collects the digest from the ReadValue/WriteValue or ReadBinaryValue/WriteBinaryValue properties. Then the application can continue with the transfer of another data over which another digest can be generated. 

SeekingForbidden Syntax:
object.SeekingForbidden = b
b = object.SeekingForbidden 

Boolean. By default it is True. True in this property denies any position changing operations over the stream (if it is seekable of course - if it is not they are not possible anyway). When a digest is generated it is important to keep the data consistency, allowing the code that drives the stream filter through SFStream to reposition anywhere in the stream usually means that the consistency will be compromised (i.e. transfer 20 bytes from the beginning of the file, then jump to the middle and transfer some bytes from there etc.). Thus usually the object would keep you from mistakes by issuing an error when the position is changed. However you can disable the processor (Both or one of them) for some time and you may want to be able to jump through the file during that time. Or there is also another possibility - the file may contain the data you want to transfer spread in different locations of the file. It is up to you to determine when the re-positioning operations will not harm the data consistency and consequently the digest generation. Setting the property to False during these periods will enable the seeking features (SFStream.Pos for example).
Please note that the described technique is usually typical for complex file structures. It is not recommended to enable the file seeking unless you really need it. 

CodePage Syntax:
object.CodePage = cp
cp = object.CodePage 

 

Stream Syntax:
Set object.Stream = strm
Set strm = object.Stream

Sets gets the stream to which the filter is attached. Generally it is possible to attach more than one filter over a real stream (i.e. this can be another filter - for example a SFStreamCrypt you use to decrypt the real stream underneath). However, most often this is a "real" stream such as a file, network connection and so on.

ReadAlgorithm
WriteAlgorithm
Syntax:
object.ReadAlgorithm = alg
alg = object.ReadAlgorithm
object.WriteAlgorithm = alg
alg = object.WriteAlgorithm

Initializes the respective processor with the algorithm specified. The algorithms have the same names as in HashObject.InitHash.

WriteKey
ReadKey
Syntax:
object.ReadKey = key
key = object.ReadKey
object.WriteKey = key
key = object.WriteKey

Specifies HMAC key for the Read or the Write processor respectively. See HashObject.Key for more comments about HMAC.

ReadBinaryValue
WriteBinaryValue
Syntax:
v = object.ReadBinaryValue
v = object.WriteBinaryValue
 

 

ReadValue
WriteValue
Syntax:
v = object.ReadValue 
v = object.WriteValue

 

...

newObjects Copyright 2001-2006 newObjects [ ]