|
|
Class: HashStream
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
Abstract class. Subclasses generate hash values used as checksums
or for generating cryptographic signatures.
SHA1Stream
MD5Stream
compatibility - squeak
-
hashMessage: aStringOrByteArrayOrStream
-
SQUEAK compatibility
- but this is a bad choice - squeak uses #digestMessage: at the instance side
instance creation
-
new
-
have to re-allow new - it was disabled in Stream
-
random
-
create a random number generator using myself
queries
-
canStream
-
simple hash functions (squeak-ported) cannot stream.
Use hashFunction: there
self tests
-
test
-
test against testVector
-
testVector
-
define a testvector to test the implementation
** This method raises an error - it must be redefined in concrete classes **
utilities
-
digestMessage: aStringOrByteArrayOrStream
-
-
hashValueOf: aStringOrByteArrayOrStream
-
-
hashValueOfFile: aFilename
-
accessing
-
contents
-
return the entire contents of the stream
- this is our hashValue.
not implemented
-
next
-
operations
-
digestMessage: bytes
-
answer the digest of bytes
-
hmac
-
answer a hmac stream with myself
-
reset
-
initialize to a clean state
** This method raises an error - it must be redefined in concrete classes **
queries
-
blockSize
-
the class knows about the basic block size
-
hashSize
-
the class knows about the basic hash size
-
hashValue
-
retunr the value of the computeted hash
** This method raises an error - it must be redefined in concrete classes **
-
isReadable
-
return true, if reading is supported by the recevier.
Always return false here
-
isWritable
-
return true, if writing is supported by the recevier.
Always return true here
testing
-
atEnd
-
return true if the end of the stream has been reached;
this is never reached
writing
-
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 **
-
nextPutAll: aCollection
-
Hash streams handle Strings and ByteArrays in nextPut:
-
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
|