eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'HashStream':

Home

everywhere
www.exept.de
for:
[back]

Class: HashStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--HashStream
         |
         +--CRC32Stream
         |
         +--MD5Stream
         |
         +--SHA1Stream

Package:
stx:libbasic
Category:
System-Crypt-Hashing
Version:
rev: 1.13 date: 2010/03/04 14:34:21
user: cg
file: HashStream.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Stefan Vogel

Description:


Abstract class. Subclasses generate hash values used as checksums
or for generating cryptographic signatures.


Related information:

    SHA1Stream
    MD5Stream

Class protocol:

compatibility - squeak
o  hashMessage: aStringOrByteArrayOrStream
SQUEAK compatibility
- but this is a bad choice - squeak uses #digestMessage: at the instance side

instance creation
o  new
have to re-allow new - it was disabled in Stream

o  random
create a random number generator using myself

queries
o  canStream
simple hash functions (squeak-ported) cannot stream.
Use hashFunction: there

self tests
o  test
test against testVector

o  testVector
define a testvector to test the implementation

** This method raises an error - it must be redefined in concrete classes **

utilities
o  digestMessage: aStringOrByteArrayOrStream

o  hashValueOf: aStringOrByteArrayOrStream

o  hashValueOfFile: aFilename


Instance protocol:

accessing
o  contents
return the entire contents of the stream
- this is our hashValue.

not implemented
o  next

operations
o  digestMessage: bytes
answer the digest of bytes

o  hmac
answer a hmac stream with myself

o  reset
initialize to a clean state

** This method raises an error - it must be redefined in concrete classes **

queries
o  blockSize
the class knows about the basic block size

o  hashSize
the class knows about the basic hash size

o  hashValue
retunr the value of the computeted hash

** This method raises an error - it must be redefined in concrete classes **

o  isReadable
return true, if reading is supported by the recevier.
Always return false here

o  isWritable
return true, if writing is supported by the recevier.
Always return true here

testing
o  atEnd
return true if the end of the stream has been reached;
this is never reached

writing
o  nextPut: anObject
add the hash of anObject to the computed hash so far.
anObject can be a Character, SmallInteger, or Character-, Byte-
Integer-Array

** This method raises an error - it must be redefined in concrete classes **

o  nextPutAll: aCollection
Hash streams handle Strings and ByteArrays in nextPut:

o  nextPutBytes: count from: anObject startingAt: start
write count bytes from an object starting at index start.
Return the number of bytes written.
The object must have non-pointer indexed instvars
(i.e. be a ByteArray, String, Float- or DoubleArray).
Use with care - non object oriented i/o.
This is provided for compatibility with externalStream;
to support binary storage.

Redefined, because HashStream encodes integers as 4 bytes.
You should implement this method in subclasses



ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 19:14:02 GMT